所以我创建了一个Mern项目,并希望它部署在heroku上。但无论我做什么,推送都会被拒绝;推送被拒绝,无法编译Node.js应用程序">
这是我的package.json文件:
{
"name": "ecom",
"version": "1.0.0",
"description": "e-commerce Website",
"main": "server.js",
"engines": {
"node": "10.16.0"
},
"scripts": {
"start": "node backend/server.js",
"server": "nodemon backend/server.js",
"client": "npm start --prefix frontend",
"build": "npm install --prefix frontend && npm run build --prefix frontend",
"dev": "concurrently "npm run server" "npm run client"",
"data:import": "node backend/seederScript.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"date-fns": "^2.19.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.12.2",
"react-scripts": "^4.0.3"
},
"devDependencies": {
"concurrently": "^6.0.0",
"nodemon": "^2.0.7"
}
}
这是我的github存储库:https://github.com/gambhir-harshil/E-commerce
以下是错误的完整日志:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 10.16.0
engines.npm (package.json): unspecified (use default)
Resolving node version 10.16.0...
Downloading and installing node 10.16.0...
Using default npm version: 6.9.0
-----> Installing dependencies
Installing node modules
> core-js@2.6.12 postinstall /tmp/build_8817a311/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> ejs@2.7.4 postinstall /tmp/build_8817a311/node_modules/ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
> core-js@3.10.0 postinstall /tmp/build_8817a311/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.10.0 postinstall /tmp/build_8817a311/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
> nodemon@2.0.7 postinstall /tmp/build_8817a311/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 1930 packages in 24.695s
-----> Build
Running build
> ecom@1.0.0 build /tmp/build_8817a311
> npm install --prefix frontend && npm run build --prefix frontend
> core-js@2.6.12 postinstall /tmp/build_8817a311/frontend/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js@3.10.0 postinstall /tmp/build_8817a311/frontend/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.10.0 postinstall /tmp/build_8817a311/frontend/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
> ejs@2.7.4 postinstall /tmp/build_8817a311/frontend/node_modules/ejs
> node ./postinstall.js
added 1885 packages from 819 contributors and audited 1889 packages in 52.962s
found 0 vulnerabilities
> frontend@0.1.0 build /tmp/build_8817a311/frontend
> react-scripts build
Creating an optimized production build...
Failed to compile.
./node_modules/@material-ui/icons/utils/createSvgIcon.js
Cannot find module: '@material-ui/core/utils'. Make sure this package is installed.
You can install this package by running: npm install @material-ui/core/utils.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@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.pNfTf/_logs/2021-04-05T04_59_12_835Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ecom@1.0.0 build: `npm install --prefix frontend && npm run build --prefix frontend`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ecom@1.0.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.pNfTf/_logs/2021-04-05T04_59_12_851Z-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:
- 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
build
脚本引用client
,但client
目录不存在。它应该是frontend
。
"build": "npm install --prefix frontend && npm run build --prefix frontend"