问题
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
- merge-descriptors
- finalhandler
- debug
- encodeurl
- escape-html
- esm
etc...
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"
}
}
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 > MERN_1@1.1.0 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! MERN_1@1.1.0 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 MERN_1@1.1.0 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
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.
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?
回答1:
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.
来源:https://stackoverflow.com/questions/58380759/multiple-modules-not-found-when-deploying-app-ibm-cloud