-1

Generally when you browse a module on npm there is no node_modules there. It's as far as I know an anti-pattern to upload your node_modules/ to npm. That's supposed to be created and populated by the client when they run npm install.

For an example of this take the popular Node.js library, Ramda.

Now compare that to the upstream npm module

Why does just npm ship the node_modules/ directory?


Follow up question "How do package.json's version numbers function when bundling a node_modules/ directory for your dependencies?"

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

0

It's as far as I know an anti-pattern to upload your node_modules/ to npm.

It's not an anti-pattern, some modules like to include their dependencies in the bundle.

I like to do that as well [with pure JS dependencies] since it kind of decouples the dependency from npm itself.

There's an option in package.json that does just that:

bundleDependencies

This defines an array of package names that will be bundled when publishing the package.

In cases where you need to preserve npm packages locally or have them available through a single file download, you can bundle the packages in a tarball file by specifying the package names in the bundleDependencies array and executing npm pack.

Marco
  • 7,007
  • 2
  • 19
  • 49