-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[BUG] Error installing relative paths using workspaces #3847
Comments
Had the same issue but with However, the command was working locally for me. It failed inside Docker. So I compared my host environment to the Docker one and noticed the NPM versions were slightly different.
Locally I was using v7.18.1.
Works :) Hope this helps narrowing down the issue. |
I have this same problem using npm@7.24 and npm@8. Works fine with npm@7.18.1. |
Thanks for the comments @niekcandaele and @Pitasi. I'll try 7.18.1 and see if that works |
Verified that |
I had the same issue with In my case, given that Before FROM node:16-buster
COPY package*.json ./
COPY packages/home-ui/package.json ./packages/home-ui/
RUN npm ci -w packages/home-ui After FROM node:16-buster
COPY package*.json ./
COPY packages/core/package.json ./packages/core/
COPY packages/home-ui/package.json ./packages/home-ui/
RUN npm ci -w packages/home-ui |
Hitting this same issue using workspaces with npm@8.1.2 and npm@8.3.2
|
npm@8.3.2 from time to time return this error on the package adding but the next attempt is always successful. |
Is there any workaround for this issue without downgrading to npm 7.18? |
+1 any workaround for this issue? |
This still seems to be an issue in An alternative when installing a workspace as a dependency of another workspace is to just write the directory path into the {
"dependencies": {
"@my-project/another-workspace": "file:packages/another-workspace"
} |
Another similar issue with node 17.3 npm 8.3.2: |
I'm on node
I had to update the package.json from this...
To this...
I'm new to using workspaces, but I think this likely defeats the purpose of using workspaces since each folder will now be using it's own version of |
@domgenv npm 8.1.2 is very old; can you try with v8.5.3? |
Thanks for the suggestion, @ljharb. I upgraded npm to 8.5.3 and it looks like it's still doing the same thing. I'm seeing the same thing in ovrn comment where the folder path is being removed, so the dependency is being added as |
I hope there will be a solution soon because this error literally shows that npm workspaces doesn't work. Only thing working for me is to downgrade npm to 7.18.1 version. |
For me this works: then from root: To make sure it's all wired up correctly: |
Also running into this bug. npm Like others have said |
To keep using last node version with workspaces I decided to replace npm with yarn on the project |
I had the same problem with this setup:
Switching to this layout solved the problem for me:
That also means that I changed "dependencies": {
- "@my-org/bar": "file:./packages/bar",
+ "@my-org/bar": "file:./bar",
... I would conclude that NPM workspaces don't support packages that are not in the same directory. |
I'm having trouble finding any comments in here that show how to reproduce this. A lot reference package.json files but don't specify what's in them. For starters, the package specs for workspaces should not be So as an example $ npm init -y; npm init -y -w packages/workspace-a;npm init -y -w workspace-b
$ npm install
$ $ npm ls
ws@1.0.0 /Users/wraithgar/Development/npm/scratch/ws
├── workspace-a@1.0.0 -> ./packages/workspace-a
└── workspace-b@1.0.0 -> ./workspace-b $ npm i workspace-a -w workspace-b
$ $ npm ls
ws@1.0.0 /Users/wraithgar/Development/npm/scratch/ws
├── workspace-a@1.0.0 -> ./packages/workspace-a
└─┬ workspace-b@1.0.0 -> ./workspace-b
└── workspace-a@1.0.0 deduped -> ./packages/workspace-a
$ cat workspace-b/package.json|grep workspace-a
"workspace-a": "^1.0.0" This setup references workspaces at multiple directory levels, which rely one on another, without this error. |
it is happening in the ".nvm/versions/node/v14.17.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js" on line 34 as target is set to null |
Problem exists with npm v8.7+ also. What I have noticed is this happens while using npm workspaces and one of the dependency installed as |
@wraithgar If that is the case and workspace dependency file type references are disallowed, it should be documented. Nothing in the current NPM documentation suggests this setup would result in any kind of problem. If possible, it would be nice for a more useful error to be emitted by the NPM cli in this scenario. The current error is extremely misleading. |
|
Also happening for me, trying to set a dependency between two packages in a workspace
|
Same problem: npm: 8.15.0 And thanks @shirshendubhowmick - removing all the file: dependencies from all the package.json's seems to work around the problem. |
ReproductionI ran into this issue when I was trying to set up workspaces (as part of turborepo) without really knowing what I was doing This is a small reproduction of what I did which produced this error https://github.com/alexFaunt/npm-cli-3847 WorkaroundThe manual fix i used, is explained in the readme, but essentially in your package-lock.json you'll find an entry similar to
Notice that it's of the format {{APP_NAME}}/node_modules/{{PACKAGE_NAME}} - this entry was problematic (in my case). Manually deleting it, and removing the dependency from app-1 manually stopped the errors occurring for me Hope that helps someone! |
TypeError: Cannot set property 'dev' of null
when using --workspace flag
The bug is with installing relative paths using workspaces. Minimum reproduction: $ npm init -y -w workspaces/a -w workspaces/b --include-workspace-root
$ npm i ./workspaces/a -w b Also breaks: $ npm init -y -w workspaces/a -w workspaces/b --include-workspace-root
$ cd workspaces/b
$ npm i ../../workspaces/a |
I also hit this error for a fresh workspace setup with no node_modules directories. npm 8.17.0 Running
Where npm-install was a script in the workspaces to action npm install.
This was shown from several of the workspaces, re-running the command didn't produce the error. However this is avoided by first running npm install in the workspace root.
Then running
|
Well.. the issue is a little bit more strange as I expected. I've tried to create a symbolic link manually.. Here is what I noticed: If I create a link like this
it works, but if I create a symlink like that, just going 1 step up
It creates a symlink - but that link already doesn't lead to anywhere. What's the logic of creating a symlink during installation from the file? P.S.: I have figured it out - when we create a symlink with a relative path. like |
Fixed by #5350 |
By the way. May be not directly relates to an issue - but I was able to resolve my issue by actual removing the dependency and using
in the root package and So with this way I managed even not to use relative dependencies. ( in my case nx injects them later during build ) |
Very strange - started getting this issue just now, having made no memorable change to the project structure. Just upgraded npm to 8.19.0 on node v18.4.0 and still have the issue. |
@leegee The bug as described here was fixed by the linked issue. You'll need to create a new issue with steps to reproduce so that whatever bug you are experiencing can be fixed. |
When tried to install a specific workspace with internal dependencies, I stopped getting the above error ( |
Still getting the issue, and based on #5350 (comment) saying
maybe the merge there should not have closed this issue? I'm aware that comments above say the issue was fixed, but I can't find a PR that claims to be an actual fix. Update: actually there seems two be two different error messages
My error is the latter. Might mean that #4064 shouldn't have been closed as a duplicate. |
Still getting this error. In my particular case, it happens when I bump the versions of my workspace packages to a pre-release version number, such as |
I solved this error by changing this:
into this:
But of course, the |
- Sadly this causes an issue with npm install npm/cli#3847
I hit this same thing -- steps taken:
Even then, it still did it... But only in docker. The reason was I was selectively copying only the packages a given service needed. Well, I missed one -- once it was added, the error went away. Definitely agree with with @ariofrio says above, (btw, your post really helped to diagnose my own issue, thx!)
|
The code before this change was a workaround for npm's bug (Ref. npm/cli#3847)
EDIT
See #3847 (comment) for minimum reproduction case. --@wraithgar
Is there an existing issue for this?
Current Behavior
Running
npm install --workspace=<workspace>
is resulting in npm exiting with an errorcode and the following stack trace:Dockerfile for container I'm running the command in:
node_modules seem to successfully install but npm exits with an error code
Expected Behavior
npm install completes without raising an error
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: