This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
flatten-packages with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Flatten packages in node_modules
Nested node_modules are subjectively messy and sometimes we want it to be flat. Note that your node_modules might be exploded. Use it wisely.
$ npm install -g flatten-packages
flatten-packages to rearrange all packages in node_modules folder in the project directory. Flatten will delete older version of a package. You should take care of version breaking changes related errors.
$ cd PROJECT_DIRECTORY $ flatten-packages
You can specify
PROJECT_DIRECTORY to flatten
$ flatten-packages PROJECT_DIRECTORY
PROJECT_DIRECTORY is a project directory, not a node_modules directory in
You can use info mode by adding
-i to the command. It will list all duplicate packages. Info mode do not flatten
$ flatten-packages PROJECT_DIRECTORY -i
Sometimes you need to fill dependency part of package.json. Use can use printed output using
$ flatten-packages PROJECT_DIRECTORY -p
When using automated deployment which will execute
npm install before running your nodejs script, you will need to somehow execute
flatten-packages after all dependencies are installed.