繁体   English   中英

Node.js应用程序无法部署到Heroku

[英]Node.js application fails to deploy to Heroku

我试图将应用程序部署到Heroku。 仅在更改引擎版本之后,应用程序才能成功部署。 如果我尝试不修改“引擎”部分进行部署,则部署失败并显示以下错误:

remote:        ERROR in ./resources/assets/sass/app.scss
remote:        Module build failed: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, scandir '/tmp/build_7b88e5ab3110a2273bdb09b2d4f7c673/node_modules/node-sass/vendor'

这是我的package.json

{
  "private": true,
  "name": "instagram",
  "description": "<p align=\"center\"><img src=\"https://laravel.com/assets/img/components/logo-laravel.svg\"></p>",
  "version": "1.0.0",
  "main": "webpack.config.js",
  "directories": {
    "test": "tests"
  },
  "engines" : {
    "npm" : "5.0.4",
    "node": "7.4.0",
    "yarn": "0.24.6"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^3.3.7",
    "bootstrap-notify": "^3.1.3",
    "bootstrap-sass": "^3.3.7",
    "bootstrap-switch": "^3.3.4",
    "css-loader": "^0.28.4",
    "cssnano": "^3.10.0",
    "extract-text-webpack-plugin": "^2.1.2",
    "file-loader": "^0.11.2",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "knockout": "^3.4.2",
    "node-sass": "^4.5.3",
    "nprogress": "^0.2.0",
    "optimize-css-assets-webpack-plugin": "^2.0.0",
    "sass-loader": "^6.0.6",
    "select2": "^4.0.3",
    "uglifyjs-webpack-plugin": "^0.4.6",
    "url-loader": "^0.5.9",
    "webpack": "^2.2.0",
    "webpack-cleanup-plugin": "^0.5.1"
  },
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  }
}

除了更改引擎版本,也许您有其他解决方案吗?

我找到了解决方案-在Heroku上禁用了节点模块缓存:

heroku config:set NODE_MODULES_CACHE=false
$ git commit -am 'disable node_modules cache' --allow-empty
$ git push heroku master

这是解决此问题的解决方案:

"scripts": {
  "heroku-postbuild": "yarn add --force node-sass"
}

或者,对于npm

"scripts": {
  "heroku-postbuild": "npm rebuild node-sass"
}

看到:

https://github.com/sass/node-sass/issues/1387#issuecomment-185451183

和:

https://github.com/rails/webpacker/issues/422#issuecomment-304018204

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM