0

New to Node, trying to follow a basic tutorial to launch a web browser. I'm using WebStorm as my IDE with node v22.3.0 and npm v10.8.1 and both commands are recognized by the terminal. The scripts portion of my package.json looks like:

  "scripts": {
    "launch": "node test/launch_browser.js",
},

But when I run npm run-script launch nothing happens. However, if I run the individual file it works and WebStorm uses C:\Program Files\nodejs\node.exe launch_browser.js. What is the difference? Why is it not working with npm?

1 Answer 1

0

The command to run a script from your package.json should be npm run launch instead of npm run-script launch.

Also when you edit your launch configuration for the script in WebStorm check that the following options are corrects :

  • package.json : should be the path to your package.json file
  • command should be run
  • script should be launch
  • node interpreter should be the path to your node executable
Sign up to request clarification or add additional context in comments.

2 Comments

That doesn't work either (no errors but browser doesn't open) and npm says launch is available via npm run-script. I've also verified both paths mentioned. My node interpreter is C:\Program Files\nodejs\node.exe which seems correct.
hmm it seem run-script is an alias for run so both should work. When you say it works when you run the individual file you mean with the command node test/launch_browser.js ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.