“代码ENOENT远程:npm错误!系统调用打开远程:在heroku上的mern部署中出现错误!路径

ndasle7k  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(120)

请检查我的代码,在部署我的MERN代码到Heroku时出错。我有一个MERN项目,我想在Heroku上托管,但在部署它时,我得到了一个错误:-“推送被拒绝,未能编译Node.js应用程序。推送失败”。请帮助。获取以下错误:-

remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 16.x...
remote: Downloading and installing node 16.15.1...
remote: Using default npm version: 8.11.0
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 211 packages, and audited 212 packages in 4s
remote:
remote: 29 packages are looking for funding
remote: run npm fund for details
remote:
remote: found 0 vulnerabilities
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > backend@1.0.0 heroku-postbuild
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix frontent && npm run build --prefix frontend
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_d76ff38e/frontent/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_d76ff38e/frontent/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.aguxs/_logs/2022-06-14T14_40_07_661Z-debug-0.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:

主要是错误行:-

remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_d76ff38e/frontent/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_d76ff38e/frontent/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.aguxs/_logs/2022-06-14T14_40_07_661Z-debug-0.log
0g0grzrc

0g0grzrc1#

我遇到了同样的问题,我删除了package.json中的脚本命令:

"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"

一切都很顺利。

相关问题