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.

`npm prune --production` issue

See original GitHub issue

Current Behavior

Currently the package setup is like this:

├── package-a
├── package-b
└── package-core

both package-a and package-b depends on package-core (which is also an unpublished package).

We did run npm prune --production per each package, otherwise the zip file is too big for lambda. But it ended up deleting the local dependency (package-core).

Expected Behavior

I wonder what would be the best way to use npm prune --production.

NOTE, I could not run npm install --production (as that local dependency package-core is managed thru lerna).

Possible Solution

Steps to Reproduce (for bugs)

  1. lerna bootstrap
  2. lerna exec – npm run build (rough command)
  3. lerna exec – npm prune --production (rough command)
lerna.json

{
  "lerna": "3.16.1",
  "version": "independent",
  "packages": [
    "packages/*"
  ],
  "npmClient": "npm",
  "npmClientArgs": [
    "--no-lockfile"
  ],
  "useWorkspaces": false
}

Context

I am trying to shrink the package size with one local, unpublished, private dependency.

But when I run npm prune --production per package, the local dependency is gone.

Your Environment

Executable Version
lerna --version 3.16.1
npm --version 6.4.1
yarn --version VERSION
node --version v8.16.0
OS Version
macOS Mojave 10.14.5

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
marcesengelcommented, Dec 15, 2021

When you had previously already installed your dependencies you can go for a lerna clean before doing lerna bootstrap -- --production - otherwise the extraneous dependencies will be kept.

1reaction
tristanHessellcommented, May 13, 2020

@chenrui333 Apologies to necropost, but in case you (or someone else) needs a potental solution.

npm prune --production --no-package-lock works to not remove packages that are not in the package-lock, which would be any hoisted or local dependencies.

However, the --no-package-lock option doesnt seem to be in the docs as a valid option for npm prune, so use it at your own risk.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm-prune
Description. This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed....
Read more >
[BUG] npm prune --production does not remove hoisted prod ...
npm prune --production does not prune node_modules installed in workspace package folders. It appears to only modify the workspace root ...
Read more >
Why doesn't `npm prune` remove folders from node_modules?
According to documentation. If the --production flag is specified, this command will remove the packages specified in your devDependencies .
Read more >
1530833 – npm prune --production fails - Red Hat Bugzilla
Description of problem: `npm prune --production` fails when devDependencies contain bins Version-Release number of selected component (if applicable): ...
Read more >
Uninstalling dev dependencies with npm by Josh Sherman
While looking into some deployment issues recently, ... Removes the devDependencies npm prune --production # Does the rest of the stuff in ...
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