Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node/NPM: Can one npm package expose more than one file?

I have made a JS library for web development, it consists of several modules, which build up multiple distribution builds. It's fine when it is distributed over cdn or for example using Bower.

But now I'm trying to publish it with NPM so that it can be consumed using Browserify. My question is how can I expose more than one main file statically so that they can be consumable by Browserify.

like image 867
Ali Shakiba Avatar asked May 29 '14 10:05

Ali Shakiba


People also ask

Can you have more than one package json file?

json file, but there is nothing inherently wrong with multiple package. json files within a repo. Some companies do use mono-repos, for which it would make total sense to have multiple package. json files.

Can you npm install multiple packages?

Installing multiple packages using package. When you run the npm install command without specifying any package name, then npm will look for an existing package. json file in the current working directory. npm will install all packages listed as dependencies of the project.

Can npm packages contain malware?

If you find malware in an npm package (either yours or someone else's), you can report it to the npm Security team to help keep the Javascript ecosystem safe. Note: Vulnerabilities in npm packages should be reported directly to the package maintainers. We strongly advise doing this privately.

What happens when you run npm install twice?

Running npm install twice creates wrong package-lock.


1 Answers

you don't need to do anything.

require('my-library') // will require the `main` entry point
require('my-library/some-other-file') // will require a different file
like image 173
Jonathan Ong Avatar answered Nov 15 '22 18:11

Jonathan Ong