我尝试运行 npm run build
输出如下错误:
root@tim-VPCEB42EG:/home/tavinder/es6# npm run build
npm ERR! Linux 4.15.0-39-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! missing script: build
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/tavinder/es6/npm-debug.log
最佳答案
这意味着您缺少一个脚本。NPM 应该知道执行该命令时要运行哪个脚本。如果您有构建脚本,请在 package.json 的脚本下:
"scripts": {
"test": "jest"
"build": "name of your build script"
},
例如,在我的一个项目中,
"scripts": {
"lint": "./node_modules/.bin/eslint .",
"lint:fix": "./node_modules/.bin/eslint . --fix || true",
"build": "babel src -d dist --presets es2015",
.....
}
关于node.js - 如何修复使用命令 npm run build 时显示的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53570620/