[英]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.