Why is my one computer including dev dependencies when packaging a Serverless Framework project but my other computer is not?
When packaging and deploying my Serverless project targeted for AWS, I found that the zip package contained dev dependencies in the node_modules folder. This only happened on one of my two computers. When performing the same build steps on AWS CodeBuild, the package was also ok with not including dev dependencies.
package.json
{
"name": "project-name",
"version": "0.0.1",
"description": "description",
"main": "index.js",
"dependencies": {
"amazon-cognito-identity-js": "^3.0.10",
"aws-sdk": "^2.488.0",
"axios": "^0.18.0",
"js-sha256": "^0.9.0",
"jsonwebtoken": "^8.5.1",
"jwk-to-pem": "^2.0.1",
"node-fetch": "^2.3.0",
"uuid": "^3.3.2",
"lodash": "^4.17.11"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-node": "^4.0.0",
"mocha": "^6.0.2",
"serverless": "^1.69.0",
"sinon": "^7.4.2",
"sinon-test": "^2.4.0"
},
"scripts": {
"test": "mocha ./test --recursive"
},
"repository": {
"type": "git",
"url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/reponame"
},
"author": "",
"license": "ISC"
}
serverless.yml file that tried packaging but included dev dependencies.
service: service-name
# pinning serverless version for this project so all contributors are using the same version for consisten results
frameworkVersion: ">=1.60.0"
provider:
name: aws
runtime: nodejs10.x
stage: ${opt:stage, 'dev'} # default stage to use, unless overridden on command lin
region: us-east-1
functions:
create:
handler: create/index.create
events:
- http:
path: /{id}
method: post
cors: true
Both computers were windows 10 with the following Node versions - npm version 6.4.1 - node version 10.15.3
I tried completely uninstalling Node.js from my Windows computer following Uninstall Node.js and reinstalling Node.js but it did not work.
I tried searching for other node_modules folders on my computer and removing them but the project still included the dev dependencies.
I tried building a simple Serverless project but it also included the dev dependencies.