codeape
codeape

Reputation: 100756

npm install from local packages only

I'm familiar with Python's package manager pip. Pip has an option to specify "never make any network calls, all packages and dependencies should be fetched from a local directory".

Is something similar possible with npm?

I want a lighter weight build process, and want all the node packages to be installed from a local folder with .tgz files or similar.

Upvotes: 4

Views: 4491

Answers (1)

peteb
peteb

Reputation: 19418

If the folder in question will be used as a package repository of sorts, I think npm link should do the job

cd ~/<local-packages-dir>/<pkg>
npm link

cd ~/<project-dir>
npm link <pkg> // installs package to ~/<project-dir>/node_modules/<pkg>

Any changes to made to ~/<local-packages-dir>/<pkg> after being linked will be reflected in ~/<project-dir>/node_modules/<pkg>.


Also to note, npm install will install a tarball or a folder directly

npm install <folder>:

Install a package that is sitting in a folder on the filesystem.

npm install <tarball file>:

Install a package that is sitting on the filesystem. Note: if you just want to link a dev directory into your npm root, you can do this more easily by using npm link.

Example:

     npm install ./package.tgz

Upvotes: 1

Related Questions