【发布时间】:2021-08-26 20:33:07
【问题描述】:
我正在尝试在 Heroku 上部署 MERN 堆栈应用程序,但在部署时遇到了一些问题,如下所示
npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_9fd3be63/client/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_9fd3be63/client/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.mlfBJ/_logs/2021-05-03T03_26_07_032Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! server@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the server@1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.mlfBJ/_logs/2021-05-03T03_26_07_059Z-debug.log
服务器的Package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"engines": {
"node": "14.x"
},
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "Umar24129",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"mongodb": "^3.6.6"
}
}
客户端的Package.json
{
"name": "react-task-tracker",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"json-server": "^0.16.3",
"react": "^17.0.2",
"react-datetime-picker": "^3.2.1",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
文件系统(文件夹层次结构)截图如下。
我对此进行了很多研究,至少在 StackOverflow 或 Github 上找不到合适的解决方案。 请帮我解决这个问题。提前致谢。
【问题讨论】:
标签: node.js reactjs git express heroku