next.js: [NEXT-832] Dev Server NPM error code ENOWORKSPACES
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000
Binaries:
Node: 18.15.0
npm: 9.6.1
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.2.5-canary.3
eslint-config-next: 13.2.4
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Dev server and NPM
Link to the code that reproduces this issue
https://github.com/joepetrillo/workspace-issue
To Reproduce
Clone the repo then npm install
then cd reproduction-app
then npm run dev
Describe the Bug
I have determined that this error happens when a nextjs (versions after 13.1.6) dev server runs in an npm workspace.
npm config get registry
is getting called sometime during the dev server startup and is throwing an error since it is not supported in workspaces.
error code ENOWORKSPACES
error This command does not support workspaces.
I initially thought this could be a turborepo issue, but it is not. More details are in the issue I initially opened (linked below).
https://github.com/vercel/turbo/issues/4183
And here is a sample error log:
0 verbose cli /Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/bin/node /Users/jpetrillo/Library/Caches/fnm_multishells/18620_1678811038524/bin/npm
1 info using npm@9.6.1
2 info using node@v18.15.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 0ms
5 timing config:load:file:/Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 0ms
8 timing config:load:env Completed in 0ms
9 info found workspace root at /Users/jpetrillo/Documents/Projects/workspace-bug
10 timing config:load:file:/Users/jpetrillo/Documents/Projects/workspace-bug/.npmrc Completed in 0ms
11 timing config:load:project Completed in 3ms
12 timing config:load:file:/Users/jpetrillo/.npmrc Completed in 0ms
13 timing config:load:user Completed in 0ms
14 timing config:load:file:/Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/etc/npmrc Completed in 0ms
15 timing config:load:global Completed in 0ms
16 timing config:load:setEnvs Completed in 0ms
17 timing config:load Completed in 5ms
18 timing npm:load:configload Completed in 5ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm config get registry
22 verbose argv "config" "get" "registry"
23 timing npm:load:setTitle Completed in 5ms
24 timing config:load:flatten Completed in 1ms
25 timing npm:load:display Completed in 1ms
26 verbose logfile logs-max:10 dir:/Users/jpetrillo/.npm/_logs/2023-03-14T16_37_32_128Z-
27 verbose logfile /Users/jpetrillo/.npm/_logs/2023-03-14T16_37_32_128Z-debug-0.log
28 timing npm:load:logFile Completed in 2ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 0ms
31 timing npm:load Completed in 15ms
32 timing command:config Completed in 0ms
33 verbose stack Error: This command does not support workspaces.
33 verbose stack at Config.cmdExec (/Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/lib/node_modules/npm/lib/base-command.js:123:29)
33 verbose stack at Npm.exec (/Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/lib/node_modules/npm/lib/npm.js:154:20)
33 verbose stack at async module.exports (/Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/lib/node_modules/npm/lib/cli.js:134:5)
34 verbose cwd /Users/jpetrillo/Documents/Projects/workspace-bug/reproduction-app
35 verbose Darwin 22.2.0
36 verbose node v18.15.0
37 verbose npm v9.6.1
38 error code ENOWORKSPACES
39 error This command does not support workspaces.
40 verbose exit 1
41 timing npm Completed in 21ms
42 verbose code 1
43 error A complete log of this run can be found in:
43 error /Users/jpetrillo/.npm/_logs/2023-03-14T16_37_32_128Z-debug-0.log
Expected Behavior
No error
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 24
- Comments: 21 (4 by maintainers)
Commits related to this issue
- chore(site): disable next telemetry https://github.com/vercel/next.js/issues/47121 — committed to mythal/boluo by uonr 3 months ago
- chore(site): disable next telemetry https://github.com/vercel/next.js/issues/47121 — committed to mythal/boluo by uonr 3 months ago
Hey folks! I’ve just seen this same error with another developer I’m working with.
We both have very similar developer environment setups, but they were seeing
ENOWORKSPACES
when runningnext dev
for an npm workspace vianpm run dev -w=client
, and I was not seeing any error. This is a brand new project we weren’t expecting any issues with, so we’ve investigated why our systems were behaving differently.Following the comments above pointing at
npm config get registry
and recent changes togetRegistry
, I added some debugging to my local Next package so we could step through the code.getRegistry
first tries to find out which package manager is being used, so we step throughgetPkgManager
:npm/9.5.0 node/v18.15.0 darwin arm64 workspaces/true
)getPkgManager
returnsyarn
for an npm workspace. My friend does not have yarn installed, so it falls toreturn 'npm'
by default.Finally, in
getRegistry
my machine runsyarn config get registry
and the other machine runsnpm config get registry
.yarn config get registry
does not raise this workspace error, butnpm config get registry
does 😅My guess is that the other folks here unable to reproduce the error have either yarn or pnpm installed, whereas people seeing the error do not.
Perhaps
getRegistry
should be updated to silently swallow this error? I’d also propose a fix forgetPkgManager
to identify npm in this case, but in practice that might just mean that more people see an unhelpful error!potential quick fix for users
Run
npx next telemetry disable
to disable Next telemetry. That skips this whole check so you’ll see no error, and I’ve also found it’s madenext dev
start up faster for me 🙂Thank you!
As an alternative, if you don’t want to use
npx next telemetry disable
you can set this environment variable inside your.env
fileNEXT_TELEMETRY_DISABLED=1
Disabling telemetry fixes this for me! I can also confirm that I do not have yarn or pnpm installed.
I guess I’m not sharing any data with Vercel for the time being 😆
Thanks for looking into this! I should have been more clear - this error does NOT happen on 13.1.6. Every major release AFTER 13.1.6 does throw this error. I had a few other people try to reproduce and they got the same error, it’s strange it’s not happening for you.
I will try to figure out exactly what canary version it started on.
Yep - fixed it for me!!! 🎉
I have continued using it with this error and everything seems to work fine - obviously would still be nice to have fixed.
I’m seeing the same error on next
13.2.4
. I’m using nvm version0.39.3
with nodev18.15.0
.Running
npm config get registry
in my nextjs workspace does indeed produce the exact same error. It works without issues when running in the root directory that contains all the workspaces.