node.js - 将 nodejs 应用程序部署到 heroku 时遇到问题

标签 node.js reactjs express heroku

我正在尝试将 nodejs 应用程序部署到 heroku,但在检查 heroku 日志 时出现以下错误,

sh:1: npm-run-all : not found

我的package.json 看起来像这样

 {


         "name": "web-training",
          "version": "1.0.0",
          "description": "web-training",
          "scripts": {
            "prestart": "babel-node tools/startMessage.js",
            "start": "npm-run-all --parallel open:src lint:watch test:watch",
            "open:src": "babel-node tools/srcServer.js",
            "lint": "node_modules/.bin/esw webpack.config.* src tools",
            "lint:watch": "npm run lint -- --watch",
            "test": "mocha --reporter spec tools/testSetup.js \"src/**/*.test.js\"",
            "test:watch": "npm run test -- --watch",
            "clean-dist": "npm run remove-dist && mkdirp dist-server/dist",
            "remove-dist": "node_modules/.bin/rimraf ./dist-server/dist",
            "build:html": "babel-node tools/buildHtml.js",
            "prebuild": "npm-run-all clean-dist test lint build:html",
            "build": "babel-node tools/build.js",
            "postbuild": "babel-node dist-server/server.js"
          },
          "author": "Cory House",
          "license": "MIT",
          "dependencies": {
            "babel-polyfill": "6.8.0",
            "bootstrap": "3.3.6",
            "compression": "^1.6.1",
            "express": "^4.13.4",
            "install": "^0.8.4",
            "jquery": "2.2.3",
            "material-ui": "^0.16.7",
            "npm": "^4.0.5",
            "open": "0.0.5",
            "rd-react-overlay": "^1.4.2",
            "react": "15.0.2",
            "react-dom": "15.0.2",
            "react-native-search-bar": "^2.16.0",
            "react-native-vector-icons": "^4.0.0",
            "react-redux": "4.4.5",
            "react-router": "2.4.0",
            "react-router-redux": "4.0.4",
            "react-skylight": "^0.4.1",
            "react-tap-event-plugin": "^2.0.1",
            "redux": "3.5.2",
            "redux-thunk": "2.0.1",
            "toastr": "2.1.2"
          },
          "devDependencies": {
            "axios-mock-adapter": "^1.7.1",
            "babel-cli": "6.8.0",
            "babel-core": "6.8.0",
            "babel-loader": "6.2.4",
            "babel-plugin-react-display-name": "2.0.0",
            "babel-preset-es2015": "6.6.0",
            "babel-preset-react": "6.5.0",
            "babel-preset-react-hmre": "1.1.1",
            "babel-register": "6.8.0",
            "colors": "1.1.2",
            "compression": "1.6.1",
            "cross-env": "1.0.7",
            "css-loader": "0.23.1",
            "enzyme": "2.2.0",
            "eslint": "2.9.0",
            "eslint-plugin-import": "1.6.1",
            "eslint-plugin-react": "5.0.1",
            "eslint-watch": "2.1.11",
            "eventsource-polyfill": "0.9.6",
            "expect": "1.19.0",
            "express": "4.13.4",
            "extract-text-webpack-plugin": "1.0.1",
            "file-loader": "0.8.5",
            "jsdom": "8.5.0",
            "mocha": "2.4.5",
            "nock": "8.0.0",
            "npm-run-all": "1.8.0",
            "open": "0.0.5",
            "react-addons-test-utils": "15.0.2",
            "react-search-component": "^1.1.2",
            "redux-immutable-state-invariant": "1.2.3",
            "redux-mock-store": "1.0.2",
            "rimraf": "2.5.2",
            "style-loader": "0.13.1",
            "url-loader": "0.5.7",
            "webpack": "1.13.0",
            "webpack-dev-middleware": "1.6.1",
            "webpack-hot-middleware": "2.10.0"
          },
          "repository": {
            "type": "git",
            "url": "https://github.com/XXX/YYY"
          }
}

当我在命令行中使用 npm run build 在本地运行我的应用程序时,它运行良好。 有什么建议吗?

我正在添加 Procfile 内容:

web:npm run build  

我不确定这样可以。

最佳答案

你需要将 npm-run-all 添加到你的“dependancies”,而不是你的 中的“devDependancies” >package.json

这是因为在部署到 Heroku 时,npm 在进行 production 构建时会修剪您的“devDependancies”。

关于node.js - 将 nodejs 应用程序部署到 heroku 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42671260/

相关文章:

javascript - Node js Next 不是 Passport 策略错误中的函数

node.js - Node.js中如何使用express区分HTTP请求和XML HTTP请求?

node.js - 如何使用 Mongoose 在 API 响应中包含虚拟字段?

node.js - Express 4-未调用自定义错误处理中间件

javascript - 选择/打开新下拉菜单时自动关闭下拉菜单( react )

javascript - 将文本添加到 onKeyPress react.js 的文本输入中

reactjs - 未能在 React 应用程序的故事书中应用 Material ui 覆盖

javascript - 如何在nodejsexpress中处理response和next

javascript - 在成功安装 sqlite3 后尝试运行代码时如何修复此 "module not found error"?

node.js - 在 Node.js 中存储敏感凭据的最佳方式是什么?