Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing a local module using npm?

I have a downloaded module repo, I want to install it locally, not globally in another directory?

What is an easy way to do this?

like image 350
fancy Avatar asked Nov 11 '11 01:11

fancy


People also ask

How do I run a node module locally?

Simply run: $ npx [options] <command>[@version] [command-arg]... By default, npx will check whether <command> exists in $PATH , or in the local project binaries, and execute that.

Is npm install local or global?

Local Installation of Packages: Local packages are installed in the directory where you run npm install <package-name> and they are put in the node_modules folder under this directory.

Does npm install locally by default?

It's best to install locally when relying on a package from your module, such as Node. js. This is how npm install works by default. The grunt CLI package, for example, must be installed globally before it can be used as a command-line tool.

Can we install node locally?

Using nvm (Node.js Version Manager) makes it easier to install and manage multiple versions of Node.js on a single local environment.


2 Answers

you just provide one <folder> argument to npm install, argument should point toward the local folder instead of the package name:

npm install /path 
like image 140
fancy Avatar answered Oct 25 '22 19:10

fancy


From the npm-link documentation:

In the local module directory:

$ cd ./package-dir $ npm link 

In the directory of the project to use the module:

$ cd ./project-dir $ npm link package-name 

Or in one go using relative paths:

$ cd ./project-dir $ npm link ../package-dir 

This is equivalent to using two commands above under the hood.

like image 40
Rich Apodaca Avatar answered Oct 25 '22 18:10

Rich Apodaca