javascript - `npm build` doesn't run the script named "build" in package.json -


for new module i'm trying use npm build without gulp / grunt / other specialised build tools.

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

my build.js simply

console.log('hello') 

however, running

npm build 

simply exits without printing anything, status of 0.

running:

npm install 

also normal things, not run build.js either.

how can make npm run build script?

edit: simple bash commands don't seem work, eg

"scripts": {     "build": "touch testfile" }, 

doesn't make file name.

the issue npm build internal command, described in docs:

this plumbing command called npm link , npm install. it should not called directly.

because command exists, shadows on "build": "node build.js".

the fully-qualified way run own script run-script or alias run:

$ npm run build 

npm start , others short-hand fully-qualified run-script, option when existing npm command doesn't shadow it, npm build does. basically, if built-in npm command isn't found try find , use matching 1 "scripts" package.json property.


for posterity (as others have mentioned) npm build used npm build native c/c++ node addons using node-gyp. it's not documented because happens automatically, if you're interested source code here.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -