serverless-webpack: Error: npm install failed with code 1 for installing bitbucket repository(typescipt project) as package in my ts project
Error --------------------------------------------------
Error: npm install failed with code 1 at ChildProcess.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/lib/utils.js:91:16) at ChildProcess.emit (events.js:210:5) at ChildProcess.EventEmitter.emit (domain.js:475:20) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com
Your Environment Information --------------------------- Operating System: linux Node Version: 12.14.0 Framework Version: 2.17.0 (local) Plugin Version: 4.6.0 SDK Version: n/a Components Version: 3.17.0
"serverless-webpack": "5.3.5",
"webpack": "^4.29.0",
"webpack-node-externals": "^1.7.2"
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 28 (7 by maintainers)
Delete packge-lock.JSON and node module folder. then npm install
I’m having the same issue deploying on CircleCI
@AlexRRR and @vicary thanks, i’ve found that my failing was because yarn 2 in ci by default set YARN_ENABLE_IMMUTABLE_INSTALLS to true (that in my case is not exactly immutable “by design”)
@vicary thank you so much, with that I found out that my problem when running the
sls webpackcommand on CI for external modules was related to our private npm repo which requires auth, since there was no.npmrcsetup on the.webpackdirectory it was no able to do the npm install, solved by copying the.npmrcfile to the home directory of the user running the CI build.it indeed would have been so much easier if the output was not swallowed by the child process, but again super grateful for your help!
@AlexRRR you would start from these two methods,
https://github.com/serverless-heaven/serverless-webpack/blob/6975610cccf87ce8f69389c74c8546de4123aabf/lib/packagers/yarn.js#L120-L140
https://github.com/serverless-heaven/serverless-webpack/blob/89c629e4d49ebdba5af9f69330f155df287d6506/lib/packagers/npm.js#L119-L128
Because
Util.spawnProcessis already resolving withstdoutandstderr, you only need to change the.return()and add to the logs in the following section.https://github.com/serverless-heaven/serverless-webpack/blob/5d5723ea3ed1b97fbeebb79ddbeaaaeee7693404/lib/packExternalModules.js#L395-L402
I had the same issue with npm@8.11.0 in Azure DevOps Pipeline, I solved it by downgrading npm to version 8.10.0.
Try to add the packager property in the serverless-webpack configuration informing the package manager used in the project. (npm|yarn).
Sample: serverless.ts
serverless.yml
A much better error would be appreciated. I use a private package. My build fails, but deploy works. i.e.
sls packagefails whilesls deployworks. I am not really sure how to even debug this better.I faced this issue, and it’s related to
npm installcommand. Try to go in the.webpackand manually trynpm installI am having this exact issue when running sls deploy locally. Previously it was working fine, but now it fails on npm install. Any ideas how to fix it? Or how can I get more info on the issue as “npm install failed with code 1” does not tell much
I have the same issue running on a GitHub actions workflow. I think it’s related to this issue: https://github.com/serverless-heaven/serverless-webpack/issues/781
The issue pops up on Node 14 and not on Node 16. I guess it’s related to NPM v6 vs v7 and the output of the
npm ls -prod -json -depth=1command thats being executed by serverless-webpack.@himharsh1997 I encountered the same error too after installed other private typescript package.
Could it be caused due to installed other typescript project as dependency in my project as last deployment was successful and after this change it giving this error??