Following this answer, I installed my local dependency like this:
{
"private": true,
"dependencies": {
"my_dependency": "../relative/path/to/my_dependency"
}
}
my_dependency
depends on ESLint and its plugins:
{
"name": "my_dependency",
"dependencies": {
"@typescript-eslint/eslint-plugin": "5.25.0",
"@typescript-eslint/parser": "5.25.0",
"eslint": "8.16.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-node": "11.1.0"
},
If I install my_dependency
as a path, eslint
and it's plugins are not installed in ./node_modules
, therefore eslint
CLI is not available.
However, if I publish my_dependency
on npm and install it as package name and version,
{
"private": true,
"dependencies": {
"my_dependency": "0.0.0"
}
}
eslint
and all plugins will be added in ./node_modules
.
How to get the same effect for the local dependency?
I don't want to pollute npm registry with versions just for experiment each time I make changes in my_dependency
.
Unfortunately those local path packages don't get their dependencies installed.
note: Packages linked by local path will not have their own dependencies installed when npm install is ran in this case. You must run npm install from inside the local path itself.
Source: docs.npmjs.com/...
There are quite a few ways around it but in my opinion the best one is to use a GitHub repo and optionally a branch.
So just push your code to a github repo, let's say my-npm-playground
, assuming your use your Github username is ada_lovelace
, you can link the repo like so,
{
"private": true,
"dependencies": {
"my_dependency": "ada_lovelace/my-npm-playground"
}
}