node.js - 如何修复使用命令 npm run build 时显示的错误?

标签 node.js webpack

我尝试运行 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/

相关文章:

node.js - 私有(private) NPM Sinopia 注册表安装错误

javascript - 通过 yield & co 获得 promise 的值(value)

node.js - 是否有可能在 Electron 中有一个不可点击或点击的窗口?

node.js - npm 未满足对正在安装的包的对等依赖性

css - webpack如何优化css/less?

ecmascript-6 - 如何在 Babel 和 Webpack 中动态加载模块?

node.js - 在 Electron 项目中使用不带 webpack 的带 typescript 的 Monaco Editor

javascript - 编辑现有的 PM2 进程

css - 我在我的 webpack 配置中设置 Autoprefixer 时遇到问题

webpack - 如何在 NextJS 项目的 head 标签中内联 CSS?