简体   繁体   中英

Package.json: dependency in a local directory?

I'm developing a npm package along with an application that uses it. I'm making a ton of small changes in this package and would like to be able to rerun the application after every iteration. The package is listed as a dependency in package.json file within the app.

Currently, I've got the dependency pointing to a branch in remote git repository, but I'd like to speed this process up and not have to push every change. Is it possible to list the dependency as a directory in local file system?

Try using npm link in the local directory. Should link your globally installed module to the local copy.

It turns out the easiest way to achieve this is to just link the package directory directly into node_modules .

cd node_modules
ln -is /path/to/package/directory packagename

As far as I know, you can't using package.json. Assuming your module is in /home/username/my_module, you can do this:

npm install /home/username/my_module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM