-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm v7 does not install linked packages dependencies #2339
Comments
Same behavior with |
I'd also add that for me the expected behavior for local installs This means that the dependencies of the locally installed package should end up in the top level of Having the install behavior be consistent will make it easier to develop npm packages by being able to install the package locally in development to test it out and know that it will act the same as installing it from the registry when it's published. For example, with Rollpkg: git clone [email protected]:rafgraph/rollpkg.git
mkdir test && cd test
npm init --yes
# compare package-lock.json after running the two commands
npm i --save-dev ../rollpkg
# vs
npm i --save-dev rollpkg Note that Rollpkg, a zero config build tool to create packages with Rollup and TypeScript, has Jest and ESLint as dependencies (and provides default configs for these), but let's the user call |
@rafgraph for that, jest and eslint should be peer deps - and linking with peer deps means you have to link the peer deps also. |
Not exactly peer deps, it's a default with optional override. I know this isn't a standard use case, but regardless a consistent |
@garciaalvaro if the path is set within the root directory we will resolve the dependencies in v7 but, if as you've shown, the path is outside the fs root then we treat it like a linked dep and won't resolve those deps. We understand that this is a change from v6. |
@darcyclarke Thank you for the information. |
@garciaalvaro I'm going to bring this up at our next Open RFC call & see what the consensus is in terms of supporting the old behaivour; I forgot the exact reasoning behind the change but I can imagine that it would have reduced some complexity & potentially cleaned up a number of issues/edgecases. I'll circle back here after the call on Wednesday. |
We do have the same problem im @sulu where the @darcyclarke I did read in the meeting doc that:
Is this a suggestion to add options or are here already some options to get the old behaviour back? |
Not sure if this is the same issue or if I should open a new one—please let me know. v7 (fail):
debug.log
v6 (success):
|
At this point I agree with others npm 6 should be forked and start over and or abandon npm and go to pnpm. |
Does apache/cordova-electron#229 fix this issue as well and we can we expect a fix to hit the shelves? |
@nlf Can you help me figure out how to take advantage of this fix, please? See my failed attempt to demonstrate that the issue is fixed from May 4, 2022 and my repro of the problem from Aug 24, 2021 |
@darcyclarke |
@nlf To me it seems like this bug is not fixed. I've demonstrated my failed attempt to take advantage of this fix. Can you please tell me what I did wrong or why I cannot install? It's a nice self-contained repro, so hopefully someone can show me how to make this |
@nlf The most upsetting feature here is actually that |
Facing the same issues as @jasminen |
I'm still finding |
Still facing issues with Maybe a solution to it could be somehow making my linked package refer to its own node_modules for its deps rather than searching for those in parent's. |
npm is still broken as far as I'm concerned. For what it's worth, I had to switch to using |
@wyckster interesting I failed with yarn also what version are you using of yarn? |
Yarn will correctly install the example in my repro. I just confirmed this to be true with the node:19 docker image: node v19.9.0 and yarn 1.22.19. Whereas npm v9.6.3 (which comes with that same docker image) still fails to install local dependencies of local dependencies correctly. |
I still run into issues with But today I tried |
The PR removes the `--legacy-peer-deps` since it is no longer required (`rollup-plugin-swc3` has fixed this). The PR also adds `--install-links`. By default when npm installs the linked `@swc/core` from the local folder, it will not install the transitive dependencies (`@swc/types`). `--install-links` fixes that. See also: npm/cli#2339
yarn 1.22.21 makes a full copy (not a symlink) of the local package into the node_modules folder and installs all deps properly into the projects node_modules folder. This was the last straw that made me switch to Deno two years ago, still not fixed. A locally linked package should NOT be treated any different than a package installed from a remote source. That means its deps need to be installed into the projects node_modules folder and nowhere else. |
I thought this issue was causing problems in my scenario, but then I realized the npm behavior makes sense, given the nodejs module resolution behavior. I think my scenario is pretty common so I'll elaborate in case it helps others. Scenario
Relevant Nodejs module resolution behavior.The key is the phrase "real path" in the following: https://nodejs.org/api/esm.html#resolution-algorithm-specification section
So this means that symlinks are resolved before looking for What this means is the following works:
but the following does NOT work:
Note that this has nothing to do with npm, just nodejs. That means if you want to symlink from ThoughtsOne could argue that Setting up
Given this, I can see why npm behaves like it does when requesting symlinking. |
encountered this old chestnut again today. the following workaround seems to be working for now:
|
@ljharb Hi, this is still broken on latest NodeJs version 22.9 / npm 10.8.3. |
Current Behavior:
npm v7 does not install linked local packages dependencies.
Expected Behavior:
In npm v6 the dependencies of a local linked package are installed. This means that if
app
hasmy-local-pkg
as a dependency, runningnpm install
generatesapp/node_modules
folder and alsomy-local-pkg/node_modules
(with its dependencies).In npm v7, however, only
app/node_modules
is generated.Steps To Reproduce:
I created the following repository to illustrate it. The
README.md
has the instructions on how to reproduce it.Simplified, the steps are:
./app
and./my-local-pkg
, each with their ownpackage.json
./app/package.json
:./my-local-pkg/package.json
:./app
and runnpm install
.npm version 6 produces:
while npm version 7 produces:
Compare the two outputs, npm v7 does not install
my-local-pkg
dependencies, there is no./my-local-pkg/node_modules
folder generated.Environment:
npm v7.1.2
The text was updated successfully, but these errors were encountered: