对于我正在尝试使用的新模块 npm build
没有 gulp/Grunt/其他专门的构建工具。
"scripts": {
"build": "node build.js"
},
我的 build.js 很简单
console.log('Hello')
但是,正在运行
npm build
直接退出,不打印任何内容,状态为 0。
运行:
npm install
也做了所有正常的事情,但也不运行 build.js。
如何让 npm 运行我的构建脚本?
编辑:即使是简单的 bash 命令似乎也不起作用,例如
"scripts": {
"build": "touch TESTFILE"
},
不创建具有该名称的文件。
最佳答案
不幸的是,npm build
已经是 internal 命令,如 in the docs 所述:
This is the plumbing command called by npm link and npm install. It should generally not be called directly.
因为该命令已经存在,所以它总是隐藏在您的 "build": "node build.js"
上。
运行您自己的脚本的完全合格方法是使用 run-script
or its alias run
:
$ npm run build
npm start
和其他方法是简写方式,但仅当现有 npm 命令不会像 npm build
那样隐藏它时才可以选择。
为了后代(正如其他人提到的)npm build
被 npm 用于使用 node-gyp 构建原生 C/C++ Node 插件.
关于javascript - `npm build` 没有在 package.json 中构建 't run the script named ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29939697/