简体   繁体   中英

Laravel/Vue/Heroku - Skipping 'fsevents' build as platform linux is not supported

I've been trying to deploy a fresh Laravel with Vue in Heroku and this is the error that I got.

Skipping 'fsevents' build as platform linux is not supported
npm ERR! Cannot read property 'length' of undefined

...

We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys

Some possible problems:

- Node version not specified in package.json
    https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

Love,
Heroku

Push rejected, failed to compile Node.js app.
Push failed

I have tried basic Heroku troubleshooting guide. Also, I manage to found this https://dev.to/saidichlil/comment/pn49 which doesn't seem to work base from the comment and still give it a shot and confirmed.

I am deploying from a github repo connected to heroku, by the way, and not by using Heroku CLI.

In your pacakge.json you'll want the engines declaration as @jake-price stated above and this post-build

"heroku-postbuild": "npm run production"

Also make sure your heroku/nodejs build pack is selected with the heroku/php buildpack

Your complete package.json may look something like this

{
"private": true,
"engines": {
    "node": "12.x"
},
"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "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 --disable-host-check --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 --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js",
    "heroku-postbuild": "npm run production"
},
"devDependencies": {
    "@babel/preset-react": "^7.0.0",
    "axios": "^0.19",
    "bootstrap": "^4.0.0",
    "cross-env": "^7.0",
    "jquery": "^3.2",
    "laravel-mix": "^5.0.1",
    "lodash": "^4.17.19",
    "popper.js": "^1.12",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "resolve-url-loader": "^3.1.0",
    "sass": "^1.15.2",
    "sass-loader": "^8.0.0"
}
}

Try and put what version of Node you want Heroku to use in your package.json

"engines": {
    "node": "12.x"
}

If that doesn't work, you can also try and install it with the following command. This will skip the optional fsevents package (which isn't needed on Linux)

npm install --no-optional

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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