Spontaneous Error: npm ls -json -prod -long -all failed with code 1 when running serverless deploy or package
See original GitHub issueError: npm ls -json -prod -long -all failed with code 1
at ChildProcess.<anonymous> (/Users/mishabruml/****/node_modules/serverless-esbuild/dist/utils.js:53:24)
at ChildProcess.emit (node:events:390:28)
at ChildProcess.emit (node:domain:475:12)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
This error started spontaneously with no code or environment changes that i can work out. I have pulled down my master branch, which is working in circleci just fine, but locally I recieve the above error. I am not sure what actually causes this error as the stack trace is unclear. Is it to do with resolving dependencies across monorepo structure? For information, my project looks like:
├── package-lock.json
├── package.json
├── packages
│ ├── common
│ │ ├── src
│ │ ├── package.json
│ │ ├── tsconfig.json
│ │ └── tsconfig.lint.json
│ ├── service-a
│ │ ├── esbuild-plugins.js
│ │ ├── package.json
│ │ ├── serverless.yml
│ │ ├── src
│ │ ├── tsconfig.json
│ │ └── tsconfig.lint.json
│ └── service-b
│ ├── package.json
│ ├── src
│ └── tsconfig.json
├── tsconfig.json
└── tsconfig.lint.json
Where the packages
are managed by npm workspaces. It is service-a
that is the serverless project.
service-a package.json
{
"engines": {
"node": "^16.12.0",
"npm": "^8.1.0"
},
"version": "1.0.0",
"description": "service-a",
"license": "ISC",
"scripts": {
"tsc:check": "tsc -b --listFiles",
"eslint": "DEBUG=eslint:cli-engine eslint .",
"prettier": "prettier . --check",
"test": "jest",
"sls:deploy": "SLS_DEBUG=* rm -rf .build && sls deploy",
"sls:package": "rm -rf .build && sls package"
},
"devDependencies": {
"@aws-sdk/types": "^3.38.0",
"@emarketeer/esbuild-plugin-tsc": "^0.4.1",
"@tsconfig/node16": "^1.0.2",
"@types/aws-lambda": "^8.10.84",
"@types/http-errors": "^1.8.2",
"@types/jest": "^27.0.2",
"@types/node": "^14.17.20",
"esbuild": "^0.14.18",
"esbuild-plugin-tsc": "^0.3.0",
"jest": "^27.2.4",
"serverless": "^3.1.1",
"serverless-esbuild": "^1.23.4",
"serverless-offline": "^8.5.0",
"serverless-step-functions": "^3.5.1",
"ts-jest": "^27.0.5",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
},
"dependencies": {
"@faker-js/faker": "^6.0.0-alpha.7",
"@kafkajs/confluent-schema-registry": "^3.2.0",
"@middy/core": "^2.5.2",
"@middy/http-json-body-parser": "^2.5.7",
"@middy/http-response-serializer": "^2.5.7",
"@middy/ssm": "^2.5.2",
"@middy/validator": "^2.5.7",
"@typedorm/common": "^1.14.9",
"@typedorm/core": "^1.14.9",
"@types/convict": "^6.1.1",
"avsc": "^5.7.3",
"convict": "^6.2.1",
"http-errors": "^2.0.0",
"kafkajs": "^1.15.0",
"middy-zod-validator": "^1.0.5",
"reflect-metadata": "^0.1.13",
"uuid": "^8.3.2",
"zod": "^3.11.6"
}
}
service-a/esbuild-plugins.js
module.exports = [
require("@emarketeer/esbuild-plugin-tsc")({
force: true,
}),
];
service-a/serverless.yml
plugins:
- serverless-esbuild
- serverless-step-functions
- serverless-offline
custom:
esbuild:
plugins: esbuild-plugins.js
external:
- "@typedorm/core"
- "@typedorm/common"
sourcemap: true
package:
individually: true
npm ls -json -prod -all --depth 0
in service-a
dir yields:
{
"version": "1.0.0",
"name": "service-a",
"dependencies": {
"@faker-js/faker": {
"version": "6.0.0-alpha.7",
"resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-6.0.0-alpha.7.tgz"
},
"@kafkajs/confluent-schema-registry": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/@kafkajs/confluent-schema-registry/-/confluent-schema-registry-3.2.1.tgz"
},
"@middy/core": {
"version": "2.5.7",
"resolved": "https://registry.npmjs.org/@middy/core/-/core-2.5.7.tgz"
},
"@middy/http-json-body-parser": {
"version": "2.5.7",
"resolved": "https://registry.npmjs.org/@middy/http-json-body-parser/-/http-json-body-parser-2.5.7.tgz"
},
"@middy/http-response-serializer": {
"version": "2.5.7",
"resolved": "https://registry.npmjs.org/@middy/http-response-serializer/-/http-response-serializer-2.5.7.tgz"
},
"@middy/ssm": {
"version": "2.5.7",
"resolved": "https://registry.npmjs.org/@middy/ssm/-/ssm-2.5.7.tgz"
},
"@*******/avro-kafkajs": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@*******/avro-kafkajs/-/avro-kafkajs-0.8.1.tgz"
},
"@*******/castle": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@*******/castle/-/castle-0.8.1.tgz"
},
"@sinclair/typebox": {
"version": "0.23.4",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.4.tgz"
},
"@typedorm/common": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/@typedorm/common/-/common-1.14.9.tgz"
},
"@typedorm/core": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/@typedorm/core/-/core-1.14.9.tgz"
},
"@types/convict": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@types/convict/-/convict-6.1.1.tgz"
},
"avsc": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/avsc/-/avsc-5.7.3.tgz"
},
"convict": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/convict/-/convict-6.2.1.tgz"
},
"http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz"
},
"kafkajs": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/kafkajs/-/kafkajs-1.16.0.tgz"
},
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz"
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz"
},
"zod": {
"version": "3.13.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.13.2.tgz"
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
I keep getting "Error: npm.cmd ls -prod -json -depth=1 failed ...
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 ......
Read more >serverless/serverless - Gitter
Hey everyone, I'm just getting up and running on the Serverless tool suit deploying an AWS Lambda function running node. I'm having a...
Read more >Troubleshooting Cloud Functions - Google Cloud
Function deployment fails while executing function's global scope. This error indicates that there was a problem with your code. The deployment pipeline ...
Read more >terraform-aws-modules/lambda/aws
This Terraform module is the part of serverless.tf framework, which aims to simplify all operations when working with the serverless in ...
Read more >Esbuild - Serverless Framework: Plugins
serverless -esbuild. Serverless plugin for zero-config JavaScript and TypeScript code bundling using promising fast & furious esbuild bundler and minifier.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks a lot for this
hmm. I tried adding
{ npmError: 'code ELSPROBLEMS', log: false }
to theignoredNpmErrors
here https://github.com/floydspace/serverless-esbuild/blob/master/src/packagers/npm.ts#L124-L128but received the same error regardless. this seems to be due to the stringmatching in the error handling function throwing a false negative for the block of JSON that is output to stderr. I am continuing some local testing and may submit a PR 👍
JSON emitted to stderr that needs ignoring:
node -v v16.12.0
npm -v 8.1.0
I need npm 8 for npm workspaces 😁