Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
How to call a JS function with parameter passed in NPM script

I am trying to run a function by calling a npm script with an additional parameter that would provide a path to a specific file. In a simplified version it looks sort of like that:

package.json

"reset_script": "node -e 'require(\"./script_reset_db\").resetDatabase($npm_config_path)'"

script_reset_db.js

module.exports.resetDatabase = async (path) => { console.log(path) }

In a node terminal I'm executing:

npm run reset_script --path=123

But the command results in an error:

at [eval]:1:44
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:81:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:80:60)
at node:internal/main/eval_string:27:3

Do you have any idea what could be the issue?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Take a look at taskfile package it allows you to do something similar.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!