admin管理员组文章数量:1133918
For a new module I'm trying to use npm build
without gulp / Grunt / other specialised build tools.
"scripts": {
"build": "node build.js"
},
My build.js is simply
console.log('Hello')
However, running
npm build
Simply exits without printing anything, with a status of 0.
Running:
npm install
Also does all the normal things, but does not run build.js either.
How can I make npm run my build script?
Edit: even simple bash commands don't seem to work, eg
"scripts": {
"build": "touch TESTFILE"
},
Doesn't make a file with that name.
For a new module I'm trying to use npm build
without gulp / Grunt / other specialised build tools.
"scripts": {
"build": "node build.js"
},
My build.js is simply
console.log('Hello')
However, running
npm build
Simply exits without printing anything, with a status of 0.
Running:
npm install
Also does all the normal things, but does not run build.js either.
How can I make npm run my build script?
Edit: even simple bash commands don't seem to work, eg
"scripts": {
"build": "touch TESTFILE"
},
Doesn't make a file with that name.
Share Improve this question edited Jun 24, 2016 at 10:57 Flimm 150k48 gold badges273 silver badges285 bronze badges asked Apr 29, 2015 at 9:33 mikemaccanamikemaccana 123k110 gold badges425 silver badges529 bronze badges 2 |6 Answers
Reset to default 283Unfortunately npm build
is already an internal command, as described in the docs:
This is the plumbing command called by npm link and npm install. It should generally not be called directly.
Because that command already exists, it always shadows over your "build": "node build.js"
.
The fully-qualified way to run your own script is with run-script
or its alias run
:
$ npm run build
npm start
and others are the short-hand way, but is only an option when an existing npm command doesn't shadow it, like npm build
does.
For posterity (as others have mentioned) npm build
is used by npm to build native C/C++ Node addons using node-gyp.
The script named as "build" in package.json
is not special in any way. The only way to get it to run is to call:
npm run-script build
There are some names which are called automatically by npm, but "build" is not one of them. The full list is:
prepublish
,publish
,postpublish
preinstall
,install
,postinstall
preuninstall
,uninstall
,postuninstall
preversion
,version
,postversion
pretest
,test
,posttest
prestop
,stop
,poststop
prestart
,start
,poststart
prerestart
,restart
,postrestart
preCUSTOM
andpostCUSTOM
for custom script names.
OK, to run a build on its own, use:
npm run-script build
Npm build expects
A folder containing a package.json file in its root
Try using npm scripts in your package.json, like the classic npm start
I had a problem with npm run build
not printing anything. ended up using npm run build --verbose
to get the output I needed.
Don't forget to check the directory
- First, im assuming you have made a folder named "React" and opened in VS code.
- Then, you have done..(supposing) "npx create-react-app test"
- after installing all the packages and files, CHECK "package.json" file, if it exists then well sorted, if not, then re-install.
- After that, check the directory, it should be in "test". To do that, run command "cd test"
- Then, run "npm run start"
- Then, run "npm run build". And, all set ;)
本文标签: javascriptnpm build doesn39t run the script named quotbuildquot in packagejsonStack Overflow
版权声明:本文标题:javascript - `npm build` doesn't run the script named "build" in package.json - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736790828a1953080.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
install
instead. – Zaz Commented Oct 19, 2016 at 0:33