question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exclusion of devDependencies is partially broken when using Npm 7 (with some specific dependencies)

See original GitHub issue

When debugging a user problem with using Prisma and Serverless Framework together I accidentally discovered that the serverless package functionality has a problem with the recent Node version 15.14.0 when used with some of our packages.

A full reproduction is available here: https://github.com/janpio/repro6644_3 Here are full CI runs including the generated archives and their size:

The dependencies included in the project besides serverless itself are used to surface the problem: node_modules/@prisma/client should be fully included, as should the generated output in node_modules/.prisma. Not included should be prisma, which is only a devDependency or node_modules/@prisma/engines which is only used by that package.

I am not 100% sure if this is a problem on Serverless Framework side, Node side, or even somehow the Prisma side that is causing these packages and folder to not be excluded from the packaging process.

As a last resort we could tell our users to add a exclude list to their serverless configuration file of course, but I would prefer to understand the issue first.

serverless.yml
service: test-serverless-packaging

provider:
  name: aws
  runtime: nodejs12.x
  memorySize: 512
  timeout: 10
  versionFunctions: false
  tracing:
    lambda: true

functions:
  hello:
    handler: index.handler
    name: test-serverless-packaging-lambda
ls -l .serverless
total 81500
-rw-r--r-- 1 runner docker     2077 Apr 20 22:58 cloudformation-template-create-stack.json
-rw-r--r-- 1 runner docker     5398 Apr 20 22:58 cloudformation-template-update-stack.json
-rw-r--r-- 1 runner docker    10697 Apr 20 22:58 serverless-state.json
-rw-r--r-- 1 runner docker 83427975 Apr 20 22:58 test-serverless-packaging.zip

Installed version

Framework Core: 2.37.0 (local)
Plugin: 4.5.3
SDK: 4.2.2
Components: 3.8.3

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FirstSannycommented, Jun 3, 2021

Not sure if that is happening here aswell, but i wanted to share what broke my deploy process. Since npm 7 they automatically install the peer dependencies aswell.
And since these arent listet under dev, they are getting deployed with all the dependencies they had. Had to change the call i made to be safe to not deploy devDependencies from:

npm prune --production
sls deploy

to:

npm prune --production --omit=peer
sls deploy
1reaction
janpiocommented, Apr 22, 2021

Oh right, Npm 7 makes total sense here - much more than Node. I updated the issue title.

I have a hunch why Npm might be thinking differently here, but let me double check. Possibly this is a new feature of Npm 7 that we are triggering somehow. Will get back to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does npm install exclude dev dependencies? - Stack Overflow
Yes dev dependencies will be installed in npm install only way it wont install dev dependencies is when NODE_ENV is set to production;...
Read more >
npm-check-updates
npm -check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions. maintains existing semantic ...
Read more >
Learning the Basics - Gradle User Manual
At runtime, Gradle will locate the declared dependencies if needed for operating a specific task. The dependencies might need to be downloaded from...
Read more >
Go Modules Reference - The Go Programming Language
When a go.mod file is parsed, its content is broken into a sequence of tokens. ... A module may also be excluded at...
Read more >
Should you Pin your JavaScript Dependencies?
The pros and cons of dependency pinning for JavaScript/npm. ... Once you start using a tool/service like Renovate, probably the biggest decision you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found