Lets say im working on an app, MyApp, and I want to build an NPM module for it, MyModule. Right now I can think of two ways to develop it:
What I'd like is an easier workflow. One where I can simply save the file, refresh the page, and my changes are there. Is that possible? For example, I know in Gemfiles I can just link to another directory as the path. Pretty sure I can't do that with npm tho.
With your NPM package local to your machine, you'll need a way to reference/install it in the test application. Inside of the original NPM package directory, run npm link from the command line. This command will allow us to simulate installing this NPM package without it actually being published.
You can install a package locally if you want to depend on the package from your own module, using something like Node. js require . This is npm install 's default behavior.
Installing a package with dist-tags To override this behavior, use the command below (where tag is the package's tag like beta , latest , etc.). npm install <package_name>@<tag>. To install a specific version of the ExpressJS library, type: npm install express@beta.
You're looking for the npm link
command, which is a two steps process:
npm link
from your MyModule
directory: this will create a global package symlinked to the MyModule
directorynpm link MyModule
from your MyApp
directory: this will create a MyModule
folder in node_modules
, symlinked to the global symlink (and thus to the real location of MyModule
).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With