在heroku上部署时出错,/bin/sh: 1: webpack: not found

2024-05-20

这是我在 heroku 网站上手动部署时遇到的错误。首先,我在 .json 文件中遇到错误,因此我指定了正在运行的“npm”、“yarn”和“node”版本。这些错误似乎已经清除。现在我就是这样的人,并且已经搜索了谷歌,但似乎找不到太多关于修复它的信息。

----> Node.js app detected

-----> Creating runtime environment



       NPM_CONFIG_LOGLEVEL=error

       NPM_CONFIG_PRODUCTION=true

       NODE_VERBOSE=false

       NODE_ENV=production

       NODE_MODULES_CACHE=true

-----> Installing binaries

       engines.node (package.json):  9.4.0

       engines.npm (package.json):   5.3.0

       engines.yarn (package.json):  1.3.2



       Resolving node version 9.4.0...

       Downloading and installing node 9.4.0...

       Bootstrapping npm 5.3.0 (replacing 5.6.0)...

       npm 5.3.0 installed

       Resolving yarn version 1.3.2...

       Downloading and installing yarn (1.3.2)...

       Installed yarn 1.3.2

-----> Restoring cache

       Skipping cache restore (not-found)

-----> Building dependencies

       Installing node modules (yarn.lock)

       yarn install v1.3.2

       [1/4] Resolving packages...

       [2/4] Fetching packages...

       info [email protected] /cdn-cgi/l/email-protection: The platform "linux" is incompatible with this module.

       info "[email protected] /cdn-cgi/l/email-protection" is an optional dependency and failed compatibility check. Excluding it from installation.

       [3/4] Linking dependencies...

       warning "webpack > [email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "ajv@>=4.10.0".

       [4/4] Building fresh packages...

       $ webpack --config webpack.prod.js

       /bin/sh: 1: webpack: not found

       error Command failed with exit code 127.

       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

-----> Build failed



       We're sorry this build is failing! You can troubleshoot common issues here:

       https://devcenter.heroku.com/articles/troubleshooting-node-deploys



       If you're stuck, please submit a ticket so we can help:

       https://help.heroku.com/



       Love,

       Heroku



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

 !     Push failed

这是 .json 脚本文件:

{
  "name": "gun-c4",
  "version": "0.0.1",
  "description": "Connect four by gunDB",
  "main": "server.js",
  "scripts": {
    "build": "node node_modules/webpack/bin/webpack.js --display-error-details",
    "lint": "eslint src/",
    "start": "node server.js",
    "postinstall": "webpack --config webpack.prod.js",
    "build": "webpack",
    "build:prod": "webpack --config webpack.prod.js",
    "dev": "npm run build -- --watch"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/PsychoLlama/connect-four.git"
  },
  "keywords": [
    "connect-four",
    "game",
    "gun",
    "gunDB",
    "game",
    "real-time"
  ],
  "author": "Jesse Gibson <[email protected] /cdn-cgi/l/email-protection> (http://techllama.com)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/PsychoLlama/connect-four/issues"
  },
  "homepage": "https://github.com/PsychoLlama/connect-four#readme",
  "dependencies": {
    "connect-four": "0.0.6",
    "gun": "^0.3.992",
    "random-words": "0.0.1",
    "react": "^15.3.1",
    "react-dom": "^15.3.1",
    "react-router": "^3.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.7",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-react": "^6.11.1",
    "css-loader": "^0.26.0",
    "eslint": "^3.4.0",
    "eslint-plugin-react": "^6.2.0",
    "node-sass": "^4.0.0",
    "sass-loader": "^5.0.0",
    "style-loader": "^0.15.0",
    "webpack": "^2.2.1"
  },
  "engines": {
    "node": "9.4.0",
    "npm": "5.3.0",
    "yarn": "1.3.2"
  }
}

Thanks


尝试这个:

heroku config:set NPM_CONFIG_PRODUCTION=false

然后,在 package.json 中,将“scripts”下的“postinstall”替换为:

"heroku-postbuild": "webpack --config webpack.prod.js",

对于其他选项,请参见在 Heroku 上托管使用 Webpack 构建的生产 React 应用程序 https://stackoverflow.com/questions/41973338/hosting-a-production-react-app-built-with-wepback-on-heroku/41973881#41973881.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在heroku上部署时出错,/bin/sh: 1: webpack: not found 的相关文章

随机推荐