Closed himharsh1997 closed 2 years ago
Could you update to latest serverless-webpack
& webpack
?
Could you also share your serverless.yml
?
Also, don't remove stuff from the issue template, it avoid us asking common question like the two above ...
Will update for both.
My points:
sls deploy
the project got deployed successfully.Sorry can't give yml file info as it belong to some company.
Could you update to latest
serverless-webpack
&webpack
? Could you also share yourserverless.yml
?Also, don't remove stuff from the issue template, it avoid us asking common question like the two above ...
Not working for me when using these
"serverless-webpack": "5.5.4",
"webpack": "5.52.1",
Well, if it works locally and not on the pipeline, I guess the problem is in the pipeline and not in the library.
You should check node version, npm version, installing the project using npm install
to see if it goes well, etc.
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??
@himharsh1997 I encountered the same error too after installed other private typescript package.
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=1
command thats being executed by serverless-webpack.
I 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
asset src/apollo-server.js 236 KiB [emitted] (name: src/apollo-server)
orphan modules 103 KiB [orphan] 55 modules
runtime modules 937 bytes 4 modules
built modules 103 KiB [built]
./src/apollo-server.ts + 55 modules 103 KiB [not cacheable] [built] [code generated]
external "fs" 42 bytes [built] [code generated]
external "util" 42 bytes [built] [code generated]
webpack compiled successfully in 3897 ms
Serverless: Invoke webpack:package
Serverless: WARNING: Could not determine version of module jsonwebtoken
Serverless: WARNING: Could not determine version of module .prisma
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: reflect-metadata@^0.1.13, apollo-server-lambda@^3.3.0, graphql@^15.5.3, type-graphql@^1.1.1, class-validator@^0.13.1, jsonwebtoken, jwks-rsa@^2.0.5, @prisma/client@^2.30.0, graphql-fields@^2.0.3, uuid@^8.3.2, .prisma, axios@^0.21.4, dayjs@^1.10.7
Error ---------------------------------------------------
Error: npm install failed with code 1
at ChildProcess.<anonymous> (<path>/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)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.13.1
Framework Version: 2.66.1 (local)
Plugin Version: 5.5.1
SDK Version: 4.3.0
Components Version: 3.18.0
@afcode123 serverless-webpack
will try to create a single-use package.json
and perform npm install
with it, part of the reason is to ensure dependency completeness when you use forceInclude
and forceExclude
.
One common cause of this error comes from including or excluding packages which is not already installed in your root package.json
.
Delete packge-lock.JSON and node module folder. then npm install
Not sure if this will help anyone but was having the same issue in bitbucket with serverless@2. I downgraded my node image in the pipeline from 17.4 to 14.4 and deployed successfully without npm install failed with code 1 issue.
I faced this issue, and it's related to npm install
command. Try to go in the .webpack
and manually try npm install
I see this question in a constant rate. We can either piping the packager's stderr outwards, or simply document this behavior.
A PR is definitely appreciated.
A much better error would be appreciated. I use a private package. My build fails, but deploy works. i.e. sls package
fails while sls deploy
works. I am not really sure how to even debug this better.
I'm having the same issue deploying on CircleCI
Package lock found - Using locked versions
Packing external modules: @aws-sdk/client-cloudwatch@^3.72.0, @aws-sdk/client-dynamodb@^3.72.0, @aws-sdk/lib-dynamodb@^3.72.0, @aws-sdk/smithy-client, @aws-sdk/types, deepmerge
× Stack *******-prod failed to deploy (9s)
Environment: linux, node 12.20.2, framework 3.14.0, plugin 6.2.1, SDK 4.3.2
Credentials: Local, environment variables
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Error: npm install failed with code 1
at ChildProcess.<anonymous> (/home/circleci/app/node_modules/serverless-webpack/lib/utils.js:91:16)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at maybeClose (internal/child_process.js:1022:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
Try to add the packager property in the serverless-webpack configuration informing the package manager used in the project. (npm|yarn).
Sample: serverless.ts
custom: {
webpack: {
webpackConfig: "./webpack.config.js",
packager: "npm",
includeModules: true,
},
serverless.yml
custom:
webpack:
webpackConfig: "webpack.config.js"
packager: "npm"
includeModules: true
I have the exact same issue as @mrjasan when running sls package
on AWS CodeBuild.
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.
Thx @ViniciusAlberkovics that fixed it for me.
Update - my issue was related to using a private package and not setting up the right credentials. Everything else worked fine after I fixed that.
Everyone is welcomed for contribution in either,
Please open a PR directly and ping us for reviewing.
But the plugin is working as expected, so I'll close for now.
Others may continue to add more scenarios in the comments to aid future contributors for the PR.
@vicary
- Piping error messages from the packager child process
would you happen to know how to manually do this? I am having the same issue npm install failed with code 1
described here but I am not able to tell the reason, does not seem to relate to what others have experienced. thanks!
@AlexRRR you would start from these two methods,
Because Util.spawnProcess
is already resolving with stdout
and stderr
, you only need to change the .return()
and add to the logs in the following section.
@vicary thank you so much, with that I found out that my problem when running the sls webpack
command on CI for external modules was related to our private npm repo which requires auth, since there was no .npmrc
setup on the .webpack
directory it was no able to do the npm install, solved by copying the .npmrc
file 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!
Try to press the clear runner cache button at top, as seen in this image. This worked for me. Note:- Only project maintainers has access to this button.
Dont delete package lock file after install dependancy or use yarn to install sls service
@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")
same issue/resolution as @adumat, we migrated from npm to yarn and the package broke. Here's the config fix for us
---
webpack:
packager: "yarn"
packagerOptions:
noFrozenLockfile: true
---
Try to press the clear runner cache button at top, as seen in this image. This worked for me. Note:- Only project maintainers has access to this button.
This worked for me, thank you !
Error --------------------------------------------------
Error: npm install failed with code 1 at ChildProcess. (/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)
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