I want to have a node_modules/my-package/...
environment for one of my libraries.
My package.json
is considered valid. I has a name and a version and a few other fields:
(this is node-modules/my-paclage/package.json)
{
"name": "my-package",
"version": "1.0.0",
...
}
Then I wanted to add it to the package-lock.json
file so npm knows about it. If you do not do that, an npm install ...
or npm uninstall ...
actually deletes the my-package
folder I created under node-modules/...
.
So I decided to add the info in my package-lock.json
, only I'm not able to make it work. All I added is the version like so:
(this is package-lock.json)
...
"dependencies": {
...
"my-package": {
"version": "1.0.0"
}
...
}
....
Again, the syntax per se is correct. However, with that entry, when I try to do an npm install ...
or npm uninstall ...
it tells me:
error 404 Not Found: [email protected]
What am I doing wrong?
Using the --no-save will tell npm not to remove the package from your package. json , npm-shrinkwrap. json , or package-lock. json files.
You can use npm-prune to remove extraneous packages. Extraneous packages are packages that are not listed on the parent package's dependencies list. If the --production flag is specified or the NODE_ENV environment variable is set to production, this command will remove the packages specified in your devDependencies.
The npm install command will check your node_modules folder and remove packages that are not listed as a dependency in package.
The package-lock. json file stores the version information of each installed package unchanged, and npm will use those package versions when running the npm install command.
NPM manages everything under node_modules/
. You don't want to add anything there manually.
NPM also manages package-lock.json
. It's not intended for you to modify.
To install your package, my-package
, you want to use npm install
. It will copy or symlink your package to node_modules/
, and will write out the installed version to package-lock.json
.
If your package is local and not published to NPM, you can use npm install /path-to-mypackage
. See also: https://stackoverflow.com/a/8089029/362536
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