A
A
almac2015-10-21 20:58:17
Automation
almac, 2015-10-21 20:58:17

How to remove only 'production' packages (which are listed in “dependencies” in package.json) via command line in npm?

There is a command in npm:
“npm prune --production” - removes only the dev packages listed in “devDependencies” in package.json (i.e. purge the project of all packages NOT listed in “dependencies”)
How to remove packages listed only in "dependencies"? You can manually delete folders in node_modules, but I would like to use the npm command.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2015-10-21
@Aves

On Linux, it's like this:

npm r $(node -p "Object.keys(require('./package').dependencies).join(' ')")
Something similar, probably, can be done in cmd.
In general, it's easier to remove everything and install only dev-dependencies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question