问题描述
我正在尝试部署我的应用程序,但始终无法在IBM Cloud CI / CD上运行。我的问题是总是找不到某些模块。找不到的模块列表(安装上一个模块时,每次出现一次)如下:
I am trying to deploy my app and it's always failing onto IBM cloud CI/CD. The issue I have is that there are always some modules not found. The list of modules not found (occurs once every single time when the previous one is being installed) is as follows:
- depd
- 合并描述符
- finalhandler
- 调试
- encodeurl
- 转义HTML
- esm
- depd
- merge-descriptors
- finalhandler
- debug
- encodeurl
- escape-html
- esm
等...
这种情况一直存在,但我没有继续安装更多丢失的npm软件包。
This keeps on going but I did not go down installing further more the missing npm packages.
{
"name": "MERN_1",
"version": "1.1.0",
"description": "MERN App",
"private": true,
"engines": {
"node": "^8.11.1"
},
"scripts": {
"start": "node server/server.js",
"debug": "nf --procfile Procfile-debug --port 3000 start",
"debug:legacy": "node --debug=0.0.0.0:5858 server/server.js",
"test": "nyc mocha --exit",
"dev": "nf --procfile Procfile-dev --port 3000 start",
"build": "webpack --progress --config webpack.prod.js",
"postinstall": "npm run build",
"lint": "eslint src",
"client-reload": "webpack-dev-server --host 0.0.0.0 --history-api-fallback --progress --inline --config webpack.dev-standalone.js",
"server-reload": "nodemon server/server.js"
},
"nodemonConfig": {
"env": {
"NODE_HEAPDUMP_OPTIONS": "nosignal"
}
},
"dependencies": {
"@material-ui/lab": "^4.0.0-alpha.23",
"@sendgrid/mail": "^6.4.0",
"bcrypt": "^3.0.6",
"body-parser": "^1.19.0",
"clone-deep": "^4.0.1",
"config": "^3.2.2",
"connect-mongo": "^1.3.2",
"dotenv": "^8.0.0",
"eslint": "^6.1.0",
"express": "^4.17.1",
"express-session": "^1.16.2",
"jsonwebtoken": "^8.5.1",
"log4js": "^3.0.5",
"moment": "^2.24.0",
"mongoose": "^4.13.19",
"request": "^2.88.0"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/helper-create-class-features-plugin": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"@material-ui/core": "^4.3.2",
"@material-ui/icons": "^4.1.0",
"array-move": "^2.1.0",
"axios": "^0.18.1",
"babel-loader": "^8.0.0",
"chai": "^4.0.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^3.2.0",
"foreman": "^3.0.1",
"history": "^4.9.0",
"html-webpack-plugin": "^3.2.0",
"mocha": "^5.2.0",
"node-sass": "^4.8.3",
"nodemon": "^1.12.1",
"nyc": "^14.1.1",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-redux": "^6.0.1",
"react-router-dom": "^5.0.0",
"react-sortable-hoc": "^1.9.1",
"react-virtualized": "^9.21.1",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"sass-loader": "^7.2.0",
"style-loader": "^0.21.0",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.8.0",
"webpack-merge": "^4.1.1"
}
}
当我尝试使用控制台通过ibm工具链推送完全相同的项目时(例如git push),它表示无法部署该应用程序,并且在检查日志时发现模块未找到错误。这是日志的副本:
When i tried to push the exact same project via the ibm toolchain, using the console (like git push), it says that the app cannot be deployed and when checked the logs the module not found error are there. Here is a copy of the logs:
2019-10-14T12:32:37.70-0400 [APP/PROC/WEB/0] OUT found 0 vulnerabilities
2019-10-14T12:32:38.08-0400 [APP/PROC/WEB/0] OUT > [email protected] start /home/vcap/app
2019-10-14T12:32:38.08-0400 [APP/PROC/WEB/0] OUT > node server/server.js
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR module.js:550
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR throw err;
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR ^
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR Error: Cannot find module 'merge-descriptors'
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Function.Module._resolveFilename (module.js:548:15)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Function.Module._load (module.js:475:25)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Module.require (module.js:597:17)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at require (internal/module.js:11:18)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Object.<anonymous> (/home/vcap/deps/0/node_modules/express/lib/express.js:17:13)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Module._compile (module.js:653:30)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Object.Module._extensions..js (module.js:664:10)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Module.load (module.js:566:32)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at tryModuleLoad (module.js:506:12)
2019-10-14T12:32:38.19-0400 [APP/PROC/WEB/0] ERR at Function.Module._load (module.js:498:3)
2019-10-14T12:32:38.20-0400 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
2019-10-14T12:32:38.20-0400 [APP/PROC/WEB/0] ERR npm ERR! errno 1
2019-10-14T12:32:38.20-0400 [APP/PROC/WEB/0] ERR npm ERR! [email protected] start: `node server/server.js`
2019-10-14T12:32:38.20-0400 [APP/PROC/WEB/0] ERR npm ERR! Exit status 1
2019-10-14T12:32:38.21-0400 [APP/PROC/WEB/0] ERR npm ERR!
2019-10-14T12:32:38.21-0400 [APP/PROC/WEB/0] ERR npm ERR! Failed at the [email protected] start script.
2019-10-14T12:32:38.21-0400 [APP/PROC/WEB/0] ERR npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-14T12:32:38.21-0400 [APP/PROC/WEB/0] ERR npm ERR! A complete log of this run can be found in:
2019-10-14T12:32:38.21-0400 [APP/PROC/WEB/0] ERR npm ERR! /home/vcap/app/.npm/_logs/2019-10-14T16_32_38_212Z-debug.log
2019-10-14T12:32:38.27-0400 [APP/PROC/WEB/0] OUT Exit status 1
2019-10-14T12:32:38.28-0400 [CELL/SSHD/0] OUT Exit status 0
当我尝试使用ibmcloud登录进行推送,目标--cf和cf push时,该应用程序已成功推送。我不确定错误来自哪里,因为我想继续通过工具链使用git push命令进行部署。
When i tried to push using ibmcloud login, target --cf and cf push, the app is pushed successfully. I am not sure where the error is coming from as I would like to keep deploying using the git push command via the toolchain.
请参见manifest.yml文件:
See below the manifest.yml file:
applications:
- buildpacks: ['sdk-for-nodejs']
command: npm prune --production && NODE_ENV=production npm start
domain: null
env:
NPM_CONFIG_PRODUCTION: false
NODE_MODULES_CACHE: false
host: null
instances: 1
memory: 256M
name: mern_1
timeout: 360
domain: null
host: null
我还尝试安装具有相同项目配置的新工具链,但同样失败。
I also tried installing a new toolchain with same project configuration, but it failed as well.
有人可以帮我解决这个问题吗?
Can anyone please help me fix that?
推荐答案
感谢通过删除npm prune --production&&在manifest.yml上添加到postintall脚本的package.json中,是一个很好的解决方案。就我而言,它解决了我的问题。能够成功推送。
Thanks to the ibm developers who find out that by removing npm prune --production && on the manifest.yml and adding that to the package.json on the postintall scripts, was a good turnaround solution. in my case, it solved my issue. Been able to push successfully.
这篇关于部署应用程序时未找到多个模块-IBM Cloud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!