Skip to content
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] ERR! Workspaces not supported for global packages (8.5.0+) #4477

Closed
2 tasks done
glen-84 opened this issue Feb 27, 2022 · 25 comments · Fixed by npm/config#47
Closed
2 tasks done

[BUG] ERR! Workspaces not supported for global packages (8.5.0+) #4477

glen-84 opened this issue Feb 27, 2022 · 25 comments · Fixed by npm/config#47
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@glen-84
Copy link

glen-84 commented Feb 27, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

After updating to 8.5.0 (and 8.5.2), I'm seeing the following when running a script that uses concurrently:

$ npm run lint -w client

> lint
> concurrently "npm:lint:*"

[lint:*styles] npmnpm ERR! Workspaces not supported for global packages
[lint:*scripts]
[lint:*scripts] npm ERR! A complete log of this run can be found in:
[lint:*scripts] npm ERR!     C:\Users\Glen\AppData\Local\npm-cache\_logs\2022-02-27T11_41_42_106Z-debug-0.log
[lint:*styles]  ERR! Workspaces not supported for global packages
[lint:*styles]
[lint:*styles] npm ERR! A complete log of this run can be found in:
[lint:*styles] npm ERR!     C:\Users\Glen\AppData\Local\npm-cache\_logs\2022-02-27T11_41_42_108Z-debug-0.log
[lint:*styles]
[lint:*styles] > lint:styles
[lint:*styles] > stylelint "src/**/*.{scss,vue}"
[lint:*styles]
[lint:*scripts]
[lint:*scripts] > lint:scripts
[lint:*scripts] > eslint "src/**/*.{ts,vue}" "*.js"
[lint:*scripts]
[lint:*styles] npm run lint:styles exited with code 0
[lint:*scripts] npm run lint:scripts exited with code 0

Log:

28 verbose stack Error: Workspaces not supported for global packages
28 verbose stack     at Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:138:15)
28 verbose stack     at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5)
29 verbose cwd D:\Programming\Projects\x\v4\front-end\client
30 verbose Windows_NT 10.0.22000
31 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prefix" "-g"
32 verbose node v16.14.0
33 verbose npm  v8.5.2
34 error Workspaces not supported for global packages
35 verbose exit 1

What is that "prefix" "-g" thing?

Expected Behavior

No errors.

Steps To Reproduce

  1. In Windows.
  2. Using workspaces.
  3. Run a script using concurrently.
  4. See error.

Environment

  • npm: 8.5.2
  • Node.js: 16.14.0
  • OS Name: Windows
  • System Model Name: Really?
  • npm config:
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\\Users\\Glen\\AppData\\Roaming\\npm"

; "user" config from C:\Users\Glen\.npmrc

//npm.pkg.github.com/:_authToken = (protected)

; "project" config from D:\Programming\Projects\x\v4\front-end\.npmrc

@x:registry = "https://gitlab.com/api/v4/packages/npm/"
//gitlab.com/api/v4/packages/npm/:_authToken = (protected)

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = D:\Programming\Projects\x\v4\front-end
; HOME = C:\Users\Glen
; Run `npm config ls -l` to show all defaults.
@glen-84 glen-84 added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Feb 27, 2022
@mctrafik
Copy link

Running into the same issues. Have a package that uses yarn, trying to install yarn npm install --global yarn
and getting 35 error Workspaces not supported for global packages.

@nlf nlf added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Mar 1, 2022
@nlf nlf self-assigned this Mar 1, 2022
@nlf
Copy link
Contributor

nlf commented Mar 1, 2022

thanks for the reports! the fix is linked above and will hopefully make it into this week's release

@siiron
Copy link

siiron commented Mar 25, 2022

Some of our developers still encounter this issue on Windows, using npm 8.5.5.
We have a monorepo using workspaces and NX. Every package using concurrently produces the error "ERR! Workspaces not supported for global packages".

@ljharb
Copy link
Collaborator

ljharb commented Mar 25, 2022

@siiron is concurrently installed globally, or locally?

@siiron
Copy link

siiron commented Mar 25, 2022

Locally.

@aaron5670
Copy link

aaron5670 commented Mar 30, 2022

Same issue here...

Windows 10, Node.js 16.4.2, NPM 8.5.5 and Turborepo 1.1.10.

C:\Users\aaron.vandenberg\WebstormProjects\TopVakantiehuizen-v2>npm run dev

> dev
> turbo run dev --parallel --continue

• Packages in scope: booking-api, config, importer, listings-api, ui, website
• Running dev in 6 packages
listings-api:dev: cache miss, executing dd2793e298636c42
booking-api:dev: cache miss, executing 6bd5dba625ebe19c 
website:dev: cache miss, executing 0f2fcf606b338fa0     
booking-api:dev: npm ERR! Workspaces not supported for global packages
booking-api:dev: 
booking-api:dev: npm ERR! A complete log of this run can be found in:
booking-api:dev: npm ERR!     C:\Users\aaron.vandenberg\AppData\Local\npm-cache\_logs\2022-03-30T16_19_27_348Z-debug-0.log 
listings-api:dev: npm ERR! Workspaces not supported for global packages
listings-api:dev: 
listings-api:dev: npm ERR! A complete log of this run can be found in:
listings-api:dev: npm ERR!     C:\Users\aaron.vandenberg\AppData\Local\npm-cache\_logs\2022-03-30T16_19_27_348Z-debug-0.log
website:dev: npm ERR! Workspaces not supported for global packages
website:dev: 
website:dev: npm ERR! A complete log of this run can be found in:
website:dev: npm ERR!     C:\Users\aaron.vandenberg\AppData\Local\npm-cache\_logs\2022-03-30T16_19_27_350Z-debug-0.log     

@carlocorradini
Copy link

Same, any workaround? 😟

@creativecreatorormaybenot

Use Node v16.4.0 for now @carlocorradini.

@Domiii
Copy link

Domiii commented Apr 11, 2022

I opted to downgrade to node@16.13.1. That version still works, and it also comes with npm@8.1.2 which fixes issues npm had with yalc (as documented here).

(PS: I personally recommend using volta which allows for a workaround for this bug in a single line: volta install node@16.13.1)

@ljharb
Copy link
Collaborator

ljharb commented Apr 11, 2022

You don’t need to change your node version, and shouldn’t. You can npm install -g npm@whatever instead.

@VsevolodGolovanov
Copy link

You don’t need to change your node version, and shouldn’t. You can npm install -g npm@whatever instead.

Though WebStorm would still use the old npm from the Node.js installation by default, so you'd need to change it in Project settings (Languages & Frameworks | Node.js).

@ljharb
Copy link
Collaborator

ljharb commented Apr 11, 2022

It shouldn't be able to, because the old npm is erased by npm install -g npm and replaced with the new one.

@VsevolodGolovanov
Copy link

@ljharb, note how npm install -g doesn't ask for elevated privileges. It won't be able to modify C:\Program Files\nodejs\node_modules\npm even if it tried. It installs into %APPDATA% instead.

@ljharb
Copy link
Collaborator

ljharb commented Apr 11, 2022

@VsevolodGolovanov at least on a linux system, that would fail without sudo. Perhaps there's an npm bug on windows - npm install -g should either replace the erstwhile npm, or it should fail.

@Domiii
Copy link

Domiii commented Apr 11, 2022

You don’t need to change your node version, and shouldn’t.

@ljharb npm install -g npm@... is only one possible option, and (in my experience) it won't always achieve the goal, depending on who manages which of your node/npm installations.

Of course I don't want to claim I know it all. Maybe I'm wrong about this, but it has been my experience in the past that you can have multiple node and npm versions, not be aware of that, and because of that end up with all kinds of issues (such as having multiple divergent node and npm installations). It all depends on the management system you (or some of your tools) use. For example, on Windows, you can install node and/or npm in a variety of ways, and not all installations would be aware of one another. Options include, but are not limited to:

  1. choco
  2. WinGet
  3. volta (my favourite)
  4. nvm
  5. Manual download from the site
  6. and I'm sure there is more...

I think, I had those issues happen to me on Mac as well (some 2 years ago), with n vs. homebrew or somesuch? Even on linux, you you have multiple choices, such as n plus other installers, but maybe those happen to always target the same directory or otherwise make sure not to conflict with one another, not sure.

@Domiii
Copy link

Domiii commented Apr 11, 2022

To get back to the matter at hand, can you re-open the issue until this is all fixed?

Currently I have to downgrade npm to 8.1.2 (or node to 16.13.1) to workaround this for now. (This is also necessary to make yalc work again (wclr/yalc#187).)

@adam-coster
Copy link

I'm also seeing this when running turborepo commands, with every version of npm I've tried (from 8.1.4 through 8.7).

@jakubmazanec
Copy link

I get this error even when I run simple npm -v inside a package/workspace directory in a monorepo 🤦‍♂️

@5exceptions
Copy link

use this command

npm i somepackage --workspace=submodule0

@thomai-d
Copy link

Installing npm 8.9.0 fixes this issue for me.

@uniformdevbot
Copy link

Installing npm 8.9.0 does not fix this issue for me with nodejs v16.14.2

@kit-repo-depot
Copy link

kit-repo-depot commented Jul 9, 2022

trying npm install -g npm@8.1.2 gives the same error for me, same with 8.9.0

@ghost
Copy link

ghost commented Jul 11, 2022

Potential work around for anyone running into this while running bash on Windows. The process seems to throw an error and just stops there. However, when running in Command Prompt the task seems to continue even after the error is thrown.

This doesn't solve the error but at least it identifies the error maybe to do with which terminal you're using...?

image

@mohsentaleb
Copy link

Took me a while to figure this out.
If you're on Windows, you've probably run npm set workspaces=true command before. It adds workspaces=true in %userprofile%\.npmrc file. Removing that line fixes the problem.

@jhunexjun
Copy link

Running %userprofile% in Run and looking for .npmrc is not found.
Where else the .npmrc can be located. I don't also see it inside the project directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.