Heroku,推送被拒绝

Heroku, push rejected

我在尝试将我的项目推送到 Heroku 时遇到以下错误:

-----> Building on the Heroku-20 stack

-----> Using buildpack: heroku/nodejs

-----> Node.js app detected

       

-----> Creating runtime environment

       

       NPM_CONFIG_LOGLEVEL=error

       NODE_VERBOSE=false

       NODE_ENV=production

       NODE_MODULES_CACHE=false

       

-----> Installing binaries

       engines.node (package.json):  unspecified

       engines.npm (package.json):   unspecified (use default)

       

       Resolving node version 14.x...

       Downloading and installing node 14.17.3...

       Using default npm version: 6.14.13

       

-----> Restoring cache

       Caching has been disabled because NODE_MODULES_CACHE=false

       

-----> Installing dependencies

       Installing node modules

       added 118 packages in 2.552s

       

-----> Build

       Running heroku-postbuild

       

       > market@1.0.1 heroku-postbuild /tmp/build_ece853b3

       > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client

       

       

       > core-js@2.6.12 postinstall /tmp/build_ece853b3/client/node_modules/babel-runtime/node_modules/core-js

       > node -e "try{require('./postinstall')}catch(e){}"

       

       

       > core-js@3.13.1 postinstall /tmp/build_ece853b3/client/node_modules/core-js

       > node -e "try{require('./postinstall')}catch(e){}"

       

       

       > core-js-pure@3.13.1 postinstall /tmp/build_ece853b3/client/node_modules/core-js-pure

       > node -e "try{require('./postinstall')}catch(e){}"

       

       

       > ejs@2.7.4 postinstall /tmp/build_ece853b3/client/node_modules/ejs

       > node ./postinstall.js

       

       added 1784 packages from 799 contributors and audited 1888 packages in 44.428s

       

       137 packages are looking for funding

         run `npm fund` for details

       

       found 86 vulnerabilities (83 moderate, 3 high)

         run `npm audit fix` to fix them, or `npm audit` for details

       

       > client@0.1.0 build /tmp/build_ece853b3/client

       > react-scripts build

       

       Creating an optimized production build...

       Failed to compile.

       

       ./src/App.scss

       Cannot find module 'sass'

       Require stack:

       - /tmp/build_ece853b3/client/node_modules/sass-loader/dist/utils.js

       - /tmp/build_ece853b3/client/node_modules/sass-loader/dist/index.js

       - /tmp/build_ece853b3/client/node_modules/sass-loader/dist/cjs.js

       - /tmp/build_ece853b3/client/node_modules/loader-runner/lib/loadLoader.js

       - /tmp/build_ece853b3/client/node_modules/loader-runner/lib/LoaderRunner.js

       - /tmp/build_ece853b3/client/node_modules/webpack/lib/NormalModule.js

       - /tmp/build_ece853b3/client/node_modules/webpack/lib/NormalModuleFactory.js

       - /tmp/build_ece853b3/client/node_modules/webpack/lib/Compiler.js

       - /tmp/build_ece853b3/client/node_modules/webpack/lib/webpack.js

       - /tmp/build_ece853b3/client/node_modules/react-scripts/scripts/build.js

       

       

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! client@0.1.0 build: `react-scripts build`

npm ERR! Exit status 1

npm ERR! 

npm ERR! Failed at the client@0.1.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR!     /tmp/npmcache.nm2I7/_logs/2021-07-14T00_48_14_758Z-debug.log

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! market@1.0.1 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`

npm ERR! Exit status 1

npm ERR! 

npm ERR! Failed at the market@1.0.1 heroku-postbuild script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR!     /tmp/npmcache.nm2I7/_logs/2021-07-14T00_48_14_782Z-debug.log

-----> Build failed

       

       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

       

       - A module may be missing from 'dependencies' in package.json

         https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies

       

       Love,

       Heroku

       

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

 !     Push failed

我在 package.json 中犯了一个拼写错误。更正后,我尝试将项目推送到 heroku,但出现错误 push failed。该项目在本地运行良好。

这是我根目录中的依赖项 package.json

  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cors": "^2.8.5",
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^5.13.2",
    "morgan": "^1.10.0",
    "multer": "^1.4.2"
  }

客户端 侧依赖项:

"dependencies": {
    "@testing-library/jest-dom": "^5.12.0",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^13.1.9",
    "axios": "^0.21.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-paypal-button-v2": "^2.6.3",
    "react-redux": "^7.2.4",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.3",
    "redux": "^4.1.0",
    "redux-devtools-extension": "^2.13.9",
    "redux-thunk": "^2.3.0",
    "web-vitals": "^1.1.2"
  },
  "devDependencies": {
    "node-sass": "^6.0.1"
  }

请帮忙。 谢谢

问题是 node-sass 没有安装,所以我添加了:

"postinstall": "npm rebuild node-sass && npm install --unsafe-perm -f node-sass"

在根 package.jsonscripts{}