Dependencies aren't included when they are a dependency of devDependencies
See original GitHub issueThis is a Bug Report
Description
Serverless package doesn’t correctly add node_modules when a node module is also a dependency of a devDependency
I have a package.json that contains this :
{
"name": "myapp",
"version": "1.0.0",
"private": true,
"dependencies": {
"bluebird": "^3.5.0",
"moment": "^2.18.1"
},
"devDependencies": {
"aws-sdk": "*",
"serverless": "^1.18.0"
}
}
When I run serverless package
then extract the resulting zip file, the node_modules
folder only contains a .bin
folder.
I think that this is due to the way the excludeDevDependencies
functionality works.
I’m wondering if the issue might be coming from the fact that, as the serverless
module relies on moment
and bluedbird
they are in the list of dependencies when running npm ls --dev=true
but not added back when running npm ls --prod=true
.
Similar or dependent issues:
This is probably related to #3889
Additional Data
- Serverless 1.18.0
- MacOS Sierra
- package is created correctly ( but with the devDependencies) if I use
excludeDevDependencies: false
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Is this a dependency or devDependency? - With Blue Ink
Where to put NPM modules in package.json: it's not as simple as it seems. ... that are (almost) always going to be devDependencies...
Read more >node.js - What's the difference between dependencies ...
Dev dependencies are modules which are only required during development whereas dependencies are required at runtime. If you are deploying your application, ...
Read more >Adding dependencies to a package.json file - npm Docs
Specifying dependencies and devDependencies in a package.json file ... To specify the packages your project depends on, you must list them as "dependencies"...
Read more >Do "dependencies" and "devDependencies" matter when ...
Thus, all dependencies are devDependencies . This is how VueJs and React specify their dependencies.
Read more >The difference between dependencies and devDependencies ...
When you run npm install in the root of a project with a "package.json" file, all packages in both dependencies and devDependencies are ......
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 Free
Top 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
Just a quick update for everyone who is reading this right now / is blocked by this bug.
There’s a config available to opt-out of dev dependency exclusion you can use in the meantime:
https://serverless.com/framework/docs/providers/aws/guide/packaging/#development-dependencies
Added a pull request #3975 for this. In short, a second temporary file is used for the
--prod=true
dependencies, and then lodash’s.difference()
is used to make sure we preserve any explicitly-needed dependencies: