You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] npm install <folder> doesn't install the dependencies of that package if it is not a subdir of itself. #3318
this is the intended behavior, npm install ../dir doesn't do a full installation of the package in the directory dir, it creates a link to it which does not install its dependencies. if you want to install the contents of a directory as though it were a package from the registry instead of creating a link, as of today you would need to use npm pack while in the dir directory, and then install the resulting tarball instead of the directory.
Reacted by 1Jesper1
Reacted by Doug, Adam Lacoste, Dmitry Maevsky, Victor Bjelkholm, Rezgar Cadro, Géry Ogam, roblframpton, Sandro Circi, Vladimir Drayling, Ábel Putovits and 3 more
Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If sits inside the root of your project, its dependencies may be hoisted to the top-level node_modules as they would for other types of dependencies.
"
because that second sentence is then plain wrong.
Reacted by NetherGranite, Adam Lacoste, Alex Rififi, Géry Ogam and Mwni
I've run into this as well, why is this the intended function? I was trying to test whether a project I had just split up would resolve a common dependency correctly and had to push to github before it worked correctly. Why would the folder install not resolve dependecies like all the other methods? Using npm pack unfortunately doesn't offer the same flexibility as using the folder install.
The docs certainly seem to say that this should work:
npm install <folder>:
Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If <folder> sits inside the root of your project, its dependencies may be hoisted to the top-level node_modules as they would for other types of dependencies.
Reacted by Géry Ogam, roblframpton and Luis Miguel Mejía Suárez
i also still don't get why this difference must be there, it seems that you really need to program this out to do different things..
instead of just handling a npm install the same for everything, that it just installs exactly the same as npm install packagename. All installs should just be handles the same no matter where it comes from.
It would be helpful to at least have a flag for install and ci (e.g. --recursive) to override the default behavior and install for ALL file dependencies. I agree with the others who think the intended behavior is counterintuitive, but I'd be satisfied with a workaround that doesn't require me to write special handling for some file dependencies depending on where they are relative to the package.json in question.
+1 I'm developing a public lib and, in parallel, an application that uses it (both in typescript). It is extremely annoying and complex to have to run "npm run build", "npm pack", "npm install", "npm run build" and finally "npm start"/"npm test" for every small correction and/or feature implemented. This slows down the development of applications like this by a lot, and based on the other comments, certainly other people agree with me.
Reacted by Jani Peltoniemi, roblframpton, Sandro Circi and Luis Miguel Mejía Suárez
developing a public lib and, in parallel, an application that uses it (both in typescript)
The reason we have the application in place is to validate that the library does what we want before publishing a new version.
npm install not installing the local dependencies, does not only makes our local development experience worse, but also implied introducing drastic changes to our shared GithubActions infrastructure in order to support custom installation scripts.
Activity
nlf commentedon May 28, 2021
this is the intended behavior,
npm install ../dirdoesn't do a full installation of the package in the directorydir, it creates a link to it which does not install its dependencies. if you want to install the contents of a directory as though it were a package from the registry instead of creating a link, as of today you would need to usenpm packwhile in thedirdirectory, and then install the resulting tarball instead of the directory.jcompagner commentedon May 28, 2021
Then you need to tell me what the difference is between
npm install ./dir
or
npm install ../dir
why is there a difference between those 2?
also will you then adjust the documentation?
https://docs.npmjs.com/cli/v7/commands/npm-install
"
npm install :
Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If sits inside the root of your project, its dependencies may be hoisted to the top-level node_modules as they would for other types of dependencies.
"
because that second sentence is then plain wrong.
mdkrieg commentedon Jun 24, 2021
I've run into this as well, why is this the intended function? I was trying to test whether a project I had just split up would resolve a common dependency correctly and had to push to github before it worked correctly. Why would the folder install not resolve dependecies like all the other methods? Using npm pack unfortunately doesn't offer the same flexibility as using the folder install.
Others have been complaining about this too:
npm/npm#16870
npm/npm#13734
The docs certainly seem to say that this should work:
dmaevsky commentedon Jan 12, 2022
+1 This is very confusing and should NOT be the "intended behavior". Makes the development of closely related packages a total nightmare :/
jcompagner commentedon Jan 12, 2022
i also still don't get why this difference must be there, it seems that you really need to program this out to do different things..
instead of just handling a npm install the same for everything, that it just installs exactly the same as npm install packagename. All installs should just be handles the same no matter where it comes from.
adamlacoste commentedon Jan 12, 2022
It would be helpful to at least have a flag for
installandci(e.g.--recursive) to override the default behavior and install for ALL file dependencies. I agree with the others who think the intended behavior is counterintuitive, but I'd be satisfied with a workaround that doesn't require me to write special handling for some file dependencies depending on where they are relative to the package.json in question.LoboMetalurgico commentedon Feb 14, 2023
+1 I'm developing a public lib and, in parallel, an application that uses it (both in typescript). It is extremely annoying and complex to have to run "npm run build", "npm pack", "npm install", "npm run build" and finally "npm start"/"npm test" for every small correction and/or feature implemented. This slows down the development of applications like this by a lot, and based on the other comments, certainly other people agree with me.
ansraliant commentedon Nov 20, 2023
Any idea why this is closed?
This is still the default behavior.
Well, they changed the docs:
So, if the project is outside your root, it is linked, but it's dependencies not installed.
Yehonal commentedon Mar 8, 2024
With Yarn this works, and on NPM has been broken since forever
Another reason to migrate
Mwni commentedon Sep 18, 2024
@Yehonal Can confirm
yarn installdoes exactly what you would expect fromnpm installwhen dealing with local dependencies.geryogam commentedon Sep 18, 2024
@nlf Would you care to reopen this issue or explain the benefit of the current behavior to the community?
BalmungSan commentedon Dec 10, 2024
We are in a similar situation to this:
npm installnot installing the local dependencies, does not only makes our local development experience worse, but also implied introducing drastic changes to our shared GithubActions infrastructure in order to support custom installation scripts.