Installing a Local Module Using Npm

Installing a local module using npm?

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

npm install /path

How to specify local modules as npm package dependencies

npm install now supports this

npm install --save ../path/to/mymodule

For this to work mymodule must be configured as a module with its own package.json. See Creating NodeJS modules.

As of npm 2.0, local dependencies are supported natively. See danilopopeye's answer to a similar question. I've copied his response here as this question ranks very high in web search results.

This feature was implemented in the version 2.0.0 of npm. For example:

{
"name": "baz",
"dependencies": {
"bar": "file:../foo/bar"
}
}

Any of the following paths are also valid:

../foo/bar
~/foo/bar
./foo/bar
/foo/bar

syncing updates

Since npm install <folder> adds the package in the directory as a symlink in the current project any changes to the local package are automatically synced.

NodeJS - installing local module

You can create a tarball from your-local-module with npm-pack and then install it offline using npm-install:

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. The filename must use .tar, .tar.gz, or .tgz as the extension.

How to install a npm module in current directory?

I asked this back when I was a terminal noob.
The solution was simple:

cd (navigate using the command line) to the directory you want to install the module in and then it should work fine. It is a good idea to npm init first.



Related Topics



Leave a reply



Submit