I've searched through other questions such as this one, but they all seem to be about a local npm link
stopping working for another reason than mine. I assume this is a common use-case issue, so if I'm doing something methodically wrong, I'm more than happy to take suggestions on how I should be doing it.
Principally, I have a private npm module that I'm working on called @organisation/module
. When working locally, I'll run npm link
on it, and use it within my 'host' project as npm link @organisation/module
— this all works great with hot-reloading, etc. I'll also import it as import module from '@organisation/module
.
However, since I also want to publish my local changes to npm (as @organisation/module
) from time to time, for build testing and production code, I need to run npm install @organisation/module
on the host project.
This then seems to break the implicit npm link
I set up earlier... I assume mainly because they are the same name, and npm favors an install
over a link
?
When I want to make live, local changes again, the only way I can currently get it to work is via npm uninstall @organisation/module
and then to re-link it.
Is there a way to keep the published module installed (in order to avoid careless mistakes, like forgetting to reinstall it for build testing), but always favour the local, linked instance?
Diagram for ref:
The easy fix is to use the npm audit --fix which will look for updates that can be updated to fix those automatically.
Summary. For npm install specific version, use npm install [package-name]@[version-number]. Use npm view [package-name] version to know the specific latest version of a package available on the npm registry. Use npm list [package-name] to know the specific latest version of an installed package.
Have you tried locally installing with the other method npm
provides.
npm install /absolute/path/packageName
I believe this will change your entry in package.json
to look like this:
"dependencies" {
...
"packageName": "file:../../path/to/packageName",
...
}
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