'I keep getting "Error: npm.cmd ls -prod -json -depth=1 failed with code 1" when trying to deploy AWS lambda serverless
Below is my terminal output. Is there something missing in my environment or is there a conflict with node versions? I'm using node v.10 but the repo is using node v.8
I've tried uninstalling the node-modules and running npm install
but still keep getting the same error.
I even downgraded to node v.8 but it wouldn't work with most of the packages so I had to upgrade back to v10.
Can anyone help pinpoint what the issue could be? Thanks.
$ sls deploy -f function --stage <env>
Serverless: Bundling with Webpack...
Time: 15299ms
Built at: 02/23/2021 5:08:25 PM
Asset Size Chunks Chunk Names
{resource}/serverless/router.js 6.52 MiB 0 [emitted] [big]
{resource}/serverless/router
{resource}/serverless/router.js.map 3.54 MiB 0 [emitted] [dev]
{resource}/serverless/router
{resource}/serverless/router [big] = {resource}/serverless/router.js
{resource}/serverless/router.js.map
[2] ./node_modules/moment/moment.js 170 KiB {0} [built]
[11] external "https" 42 bytes {0} [built]
[17] ./node_modules/ramda/es/index.js + 328 modules 325 KiB {0} [built]
| ./node_modules/ramda/es/index.js 12.6 KiB [built]
| ./node_modules/ramda/es/F.js 324 bytes [built]
| ./node_modules/ramda/es/T.js 321 bytes [built]
| ./node_modules/ramda/es/__.js 739 bytes [built]
| ./node_modules/ramda/es/add.js 444 bytes [built]
| ./node_modules/ramda/es/curryN.js 1.62 KiB [built]
| ./node_modules/ramda/es/addIndex.js 1.65 KiB [built]
| ./node_modules/ramda/es/adjust.js 1.35 KiB [built]
| ./node_modules/ramda/es/all.js 1.12 KiB [built]
| ./node_modules/ramda/es/max.js 445 bytes [built]
| ./node_modules/ramda/es/bind.js 1.05 KiB [built]
| ./node_modules/ramda/es/keys.js 1.96 KiB [built]
| ./node_modules/ramda/es/map.js 2 KiB [built]
| ./node_modules/ramda/es/path.js 757 bytes [built]
| ./node_modules/ramda/es/prop.js 690 bytes [built]
| + 314 hidden modules
[43] ./node_modules/axios/index.js 40 bytes {0} [built]
[79] ./{resource}/{param}.js 2.33 KiB {0} [built]
[80] ./{resource}/serverless/config.js 549 bytes {0} [built]
[273] ./{resource}/serverless/{function}.js 82 bytes {0} [built]
[274] ./{resource}/serverless/{function}/index.js 2.17 KiB {0} [built]
[275] ./{resource}/serverless/router.js 1.35 KiB {0} [built]
[276] ./utils/JWTMiddleware.js 1.31 KiB {0} [built]
[301] ./node_modules/cryptr/index.js 1.78 KiB {0} [built]
[302] ./node_modules/jsonwebtoken/index.js 276 bytes {0} [built]
[319] ./utils/CorsResponse.js 1.27 KiB {0} [built]
[320] ./{resource}/serverless/{function}.js 1.12 KiB {0} [built]
[323] ./{resource}/serverless/{function}/index.js 4.72 KiB {0} [built]
+ 1081 hidden modules
Error --------------------------------------------------
Error: npm.cmd ls -prod -json -depth=1 failed with code 1
at ChildProcess.child.on.exitCode (C:<path to node_modules>\node_modules\serverless-webpack\lib\utils.js:91:16)
at ChildProcess.emit (events.js:198:13)
at ChildProcess.EventEmitter.emit (domain.js:448:20)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259: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: win32
Node Version: 10.23.3
Framework Version: 1.60.5
Plugin Version: 3.2.7
SDK Version: 2.2.1
Components Core Version: 1.1.2
Components CLI Version: 1.4.0
Solution 1:[1]
Removing node_modules
AND package-lock.json
, followed by npm install
worked for me.
Solution 2:[2]
In my case I was using serverless-bundle
instead of serverless-webpack
. The mistake for me was with an extra field in the custom.bundle
field in serverless.yml
Extra webpack
field
custom:
bundle:
linting: false
webpack:
webpackConfig: webpack.config.js
packager: "yarn"
Without the extra webpack
field
custom:
bundle:
linting: false
webpackConfig: webpack.config.js
packager: "yarn"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Damien Monni |
Solution 2 | Jarrett |