Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serverless deploy failing, "npm.cmd ls -prod -json -depth=1 failed with code 1" #992

Closed
JonathanMSifleet opened this issue Nov 7, 2021 · 7 comments

Comments

@JonathanMSifleet
Copy link

JonathanMSifleet commented Nov 7, 2021

This is a (Bug Report)

Description

For bug reports:

  • What went wrong?
    Came back to project after 5 months and couldn't get it to deploy despite having not changed anything. Updated my webpack and serverless dependencies and I still get the same issue. When attempting to run "serverless deploy" it fails.
    I saw on Stack Overflow that deleting node_modules and package-lock.json and re-running npm install would fix it but this did not work. Downgrading to serverless 5.3.5 also did not work.

  • What was the config you used?

dependencies "dependencies": { "@aws/dynamodb-data-mapper": "^0.7.3", "@middy/core": "^2.5.3", "@middy/http-cors": "^2.5.3", "@types/query-string": "^6.3.0", "aws-sdk": "^2.1023.0", "bcryptjs": "^2.4.3", "email-validator": "^2.0.4", "jsonwebtoken": "^8.5.1", "mdbreact": "^5.1.0", "query-string": "^7.0.1", "react": "^17.0.2", "react-dom": "^17.0.2", "react-router-dom": "^6.0.1", "serverless": "^2.65.0", "serverless-s3-deploy": "^0.10.1", "source-map-support": "^0.5.20", "tslib": "^2.3.1", "ttf-loader": "^1.0.2", "uuid": "^8.3.2", "web-vitals": "^2.1.2" }, "devDependencies": { "@babel/core": "^7.16.0", "@babel/preset-env": "^7.16.0", "@babel/preset-react": "^7.16.0", "@babel/preset-typescript": "^7.16.0", "@types/aws-lambda": "^8.10.85", "@types/bcryptjs": "^2.4.2", "@types/byline": "^4.2.33", "@types/csvtojson": "^2.0.0", "@types/file-loader": "^5.0.1", "@types/html-webpack-plugin": "^3.2.6", "@types/jest": "^27.0.2", "@types/jsonwebtoken": "^8.5.5", "@types/mini-css-extract-plugin": "^2.4.0", "@types/node": "^16.11.6", "@types/node-sass": "^4.11.2", "@types/react": "^17.0.34", "@types/react-dom": "^17.0.11", "@types/react-router-dom": "^5.3.2", "@types/regenerator-runtime": "^0.13.1", "@types/sass": "^1.43.0", "@types/sass-loader": "^8.0.2", "@types/serverless": "^1.78.39", "@types/webpack": "^5.28.0", "@types/webpack-dev-server": "^4.3.1", "@typescript-eslint/eslint-plugin": "^5.3.0", "@typescript-eslint/parser": "^5.3.0", "babel-loader": "^8.2.3", "byline": "^5.0.0", "css-loader": "^6.5.1", "csvtojson": "^2.0.10", "depcheck": "^1.4.2", "eslint": "^8.2.0", "eslint-config-prettier": "^8.3.0", "eslint-config-react-app": "^6.0.0", "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-flowtype": "^8.0.3", "eslint-plugin-import": "^2.25.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.26.1", "eslint-plugin-react-hooks": "^4.2.0", "file-loader": "^6.2.0", "flowtype": "^2.0.0", "fork-ts-checker-webpack-plugin": "^6.4.0", "html-webpack-plugin": "^5.5.0", "jest": "27.3.1", "json5-loader": "^4.0.1", "mini-css-extract-plugin": "^2.4.4", "mysql2": "^2.3.2", "node-sass": "^6.0.1", "npm-check-updates": "^12.0.0", "prettier": "^2.4.1", "remove-node-modules": "^1.7.6", "sass": "^1.43.4", "sass-loader": "^12.3.0", "serverless-cloudfront-invalidate": "^1.11.0", "serverless-webpack": "^5.5.5", "source-map-loader": "^3.0.0", "style-loader": "^3.3.1", "ts-loader": "^9.2.6", "typescript": "^4.4.4", "webpack": "^5.62.1", "webpack-cli": "^4.9.1", "webpack-dev-server": "^4.4.0", "webpack-node-externals": "^3.0.0" },
  • What stacktrace or error message from your provider did you see?

    Error: npm.cmd ls -prod -json -depth=1 failed with code 1
    at ChildProcess. (C:\Users\JonathanS\Desktop\CritickerOverhaul\node_modules\serverless-webpack\lib\utils.js:91:16)
    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)

Similar or dependent issue(s):

Additional Data

  • Serverless-Webpack Version you're using: 5.5.5
  • Webpack version you're using: 5.62.1
  • Serverless Framework Version you're using: 2.65.0
  • Operating System: Windows 10 21H1
@vicary
Copy link
Member

vicary commented Nov 7, 2021

What is the output if you run npm.cmd ls -prod -json -depth=1 manually from your shell?

@JonathanMSifleet
Copy link
Author

JonathanMSifleet commented Nov 7, 2021

My bad, doesn't appear as though this is actually a serverless-webpack issue, rather a depdency issue,

error message npm ERR! code ELSPROBLEMS npm ERR! invalid: file-loader@6.2.0 C:\Users\JonathanS\Desktop\CritickerOverhaul\node_modules\file-loader { "error": { "code": "ELSPROBLEMS", "summary": "invalid: file-loader@6.2.0 C:\\Users\\JonathanS\\Desktop\\CritickerOverhaul\\node_modules\\file-loader", "detail": "" } }

@JonathanSeehagen
Copy link

Hey guys. I solved a similar situation by unquoting the yarn packager declaration.

custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
packager: yarn <= Here

@horosin
Copy link

horosin commented May 3, 2022

I had this happening in Gitlab CI only. I fought with it for two days. For now the solution is to install the latest commit from master (I don't recommend pinning it to master as it's changing dynamically).

npm i serverless-heaven/serverless-webpack#44e135a4ea53f30e3f6523fc93a9c21eeef9e1e1

Once the 5.7.1 of Serverless web pack comes out, make sure to make it a minimum required version.

@j0k3r
Copy link
Member

j0k3r commented May 10, 2022

@Sam-Moran
Copy link

I had this same issue yesterday on our Github Actions pipeline, and it appeared to happen previously but there was no obvious fix and people just waited till someone else did a PR.

For us, though I found the issue was because of lockfile versioning.

Using NPM 7 which creates a package-lock.json with lockfile v2 would cause this error if I rolled back to NPM 6 and committed a lockfile v1 the code would deploy. This was constantly reproducible.

We now use https://volta.sh/ to lock the NPM version for the time being.

@somq
Copy link

somq commented Aug 18, 2022

Hey guys. I solved a similar situation by unquoting the yarn packager declaration.

custom: webpack: webpackConfig: ./webpack.config.js includeModules: true packager: yarn <= Here

I confirm this one, thanks!
We are using yarn and not specifying the packager key would throw this error

  webpack:
    packager: 'yarn' # Packager that will be used to package your external modules
    webpackConfig: ./webpack.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants