How do you run a js file using npm scripts?

Richard :

I can't get npm to work. My package.json file has

"scripts": { "build": "build.js" }

and I have a build.js file in the same folder that just console.logs.

When I run

npm run build

I get the error

The system cannot execute the specified program.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v4.1.1
npm ERR! npm  v3.3.5
npm ERR! code ELIFECYCLE

and if I move the build.js file and change my package.json file to have a subfolder

"scripts": { "build": "build/build.js" }

then I get the error

'build' is not recognized as an internal or external command, operable program or batch file.

What's going wrong? I'm copying the example documentation.

Luca Filosofi :
{ "scripts" :
  { "build": "node build.js"}
}

npm run build OR npm run-script build


{
  "name": "build",
  "version": "1.0.0",
  "scripts": {
    "start": "node build.js"
  }
}

npm start


NB: you were missing the { brackets } and the node command

folder structure is fine:

+ build
  - package.json
  - build.js

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to run test file after launching server using npm scripts?

From Dev

npm run scripts in separate file

From Dev

How do you run an .exe file on Docker?

From Dev

How to compile typescript into javascript then into 1 file using npm scripts

From Dev

How do you run pyenv commands from an npm script?

From Dev

How do you convert a text file to CSV file while keeping text file format using JS?

From Dev

How to run npm scripts from global packages?

From Dev

how do I run multiple python scripts simultaniously using QProcess

From Dev

How do I run two commands with pipenv scripts using &&?

From Dev

How to run the bash scripts file?

From Dev

How exactly do you use NPM scripts and echo while executing a command?

From

How do you reinstall an app's dependencies using npm?

From Dev

How do I reference another JS file for Illustrator Scripts?

From Dev

run npm scripts in kudu

From Dev

Run webpack with npm scripts

From Dev

How to run .ts file script and angular 5 build using NPM

From Dev

How does "npm run build" run the scripts in jquery github repo?

From Dev

How do you run a setup.py file properly?

From

How do you run a command for each line of a file?

From Dev

How Do You Run Webpack from a JavaScript file?

From

How do you run a single test/spec file in RSpec?

From Dev

How do you run multiple karate feature file in a gatling simulation?

From Dev

How do you run a standalone ijs j file on Linux?

From Dev

How do you assemble, link and run a .s file in linux?

From Dev

How do you run code for the duration of a sound file? - Swift

From Java

How do I run a file using Java?

From Dev

How do I run a JS file from another JS file?

From Dev

How do you import a local js file into a basic html file?

From Dev

How do you run a .exe with parameters using vba's shell()?

Related Related

  1. 1

    How to run test file after launching server using npm scripts?

  2. 2

    npm run scripts in separate file

  3. 3

    How do you run an .exe file on Docker?

  4. 4

    How to compile typescript into javascript then into 1 file using npm scripts

  5. 5

    How do you run pyenv commands from an npm script?

  6. 6

    How do you convert a text file to CSV file while keeping text file format using JS?

  7. 7

    How to run npm scripts from global packages?

  8. 8

    how do I run multiple python scripts simultaniously using QProcess

  9. 9

    How do I run two commands with pipenv scripts using &&?

  10. 10

    How to run the bash scripts file?

  11. 11

    How exactly do you use NPM scripts and echo while executing a command?

  12. 12

    How do you reinstall an app's dependencies using npm?

  13. 13

    How do I reference another JS file for Illustrator Scripts?

  14. 14

    run npm scripts in kudu

  15. 15

    Run webpack with npm scripts

  16. 16

    How to run .ts file script and angular 5 build using NPM

  17. 17

    How does "npm run build" run the scripts in jquery github repo?

  18. 18

    How do you run a setup.py file properly?

  19. 19

    How do you run a command for each line of a file?

  20. 20

    How Do You Run Webpack from a JavaScript file?

  21. 21

    How do you run a single test/spec file in RSpec?

  22. 22

    How do you run multiple karate feature file in a gatling simulation?

  23. 23

    How do you run a standalone ijs j file on Linux?

  24. 24

    How do you assemble, link and run a .s file in linux?

  25. 25

    How do you run code for the duration of a sound file? - Swift

  26. 26

    How do I run a file using Java?

  27. 27

    How do I run a JS file from another JS file?

  28. 28

    How do you import a local js file into a basic html file?

  29. 29

    How do you run a .exe with parameters using vba's shell()?

HotTag

Archive