vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26k stars 1.79k forks source link

[turborepo] NPM error code ENOWORKSPACES with NextJS #4183

Closed joepetrillo closed 1 year ago

joepetrillo commented 1 year ago

What version of Turborepo are you using?

1.8.3

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Describe the Bug

Performing turbo run dev on the latest NextJS version (13.2.4) causes the ENOWORKSPACES npm error during startup.

error code ENOWORKSPACES error This command does not support workspaces.

Expected Behavior

No errors

To Reproduce

Clone the reproduction repo, run npm install and npm run dev. In the apps directory I setup two barebones nextjs starters. latest causes the issue and older does not.

This is happening for me on node version 18.15.0 and NPM version 9.6.1.

Reproduction Repo

https://github.com/joepetrillo/turbo-issue

nathanhammond commented 1 year ago

Hey @joepetrillo! I pulled down your repository and it doesn't reproduce for me.

That error is thrown here: https://github.com/npm/cli/blob/618c1baa830b0ab52fbee0016c3532411477bde7/lib/base-command.js#L122-L126

And the cause of that is one of the 28 commands that exist in npm that do not support workspaces. My only hypothesis is that it is possible that you have a global .npmrc that is causing this failure.

As I can't reproduce I'm going to close this for now. Do let us all know if you get it figured out!

~/repos/triage/4183 (main)$ npm install

added 279 packages, and audited 282 packages in 6s

102 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
~/repos/triage/4183 (main *)$ npm run dev

> dev
> turbo run dev

• Packages in scope: latest, older
• Running dev in 2 packages
• Remote caching disabled
older:dev: cache bypass, force executing b28e5bb03cd06053
latest:dev: cache bypass, force executing 0bb80629ac2dae80
latest:dev: 
latest:dev: > latest@0.1.0 dev
latest:dev: > next dev
latest:dev: 
older:dev: 
older:dev: > older@0.1.0 dev
older:dev: > next dev
older:dev: 
older:dev: ready - started server on 0.0.0.0:3000, url: http://localhost:3000
latest:dev: warn  - Port 3000 is in use, trying 3001 instead.
latest:dev: ready - started server on 0.0.0.0:3001, url: http://localhost:3001
older:dev: event - compiled client and server successfully in 854 ms (165 modules)
latest:dev: event - compiled client and server successfully in 835 ms (170 modules)
older:dev: wait  - compiling / (client and server)...
older:dev: event - compiled client and server successfully in 479 ms (194 modules)
latest:dev: wait  - compiling / (client and server)...
latest:dev: event - compiled client and server successfully in 425 ms (199 modules)
^C
latest:dev:                                                                                                                                                                          
~/repos/triage/4183 (main *)$ node --version
v18.15.0
~/repos/triage/4183 (main *)$ npm --version
9.6.1
~/repos/triage/4183 (main *)$ npm run dev -- --version

> dev
> turbo run dev --version

1.8.3
soulchild commented 1 year ago

Seeing this as well after upgrading to Next 13.2.4 from Next 13.1.6. Downgrading Next.js made it go away again. Turbo version is 1.8.3. Node is 18.15.0 with npm 9.5.0.

joepetrillo commented 1 year ago

I do not have any global .npmrc or config setup (fresh default node/NPM install). I’m surprised you didn’t get any error, do you have a .npmrc? @nathanhammond

Looks like a few others are also seeing this while using storybook.

https://github.com/storybookjs/storybook/issues/20726

Seems like the npm config command being used (which doesn’t support workspaces) could be the cause.

https://docs.npmjs.com/cli/v9/commands/npm-config

nathanhammond commented 1 year ago

@soulchild @joepetrillo do y'all have ^X.Y.Z versions in your package.json? Can you specify next to your current version (e.g. "next": "13.1.6"), and then simply delete your lockfile and reinstall to help identify which dependency is the root cause?

nathanhammond commented 1 year ago

@joepetrillo I need the rest of the npm logs that you posted in your screenshot to the other issue before I can help out. It's definitely something calling npm config, but it's not Turborepo, and it doesn't appear to be Next.js.

joepetrillo commented 1 year ago

@nathanhammond Just double checked the versioning and can confirm I am setting everything explicitly (like in the example repo). Here are screenshots of what was installed and of the lockfile.

image image

Also, here is the complete npm log:

0 verbose cli /Users/jpetrillo/Library/Application Support/fnm/node-versions/v18.15.0/installation/bin/node /Users/jpetrillo/Library/Caches/fnm_multishells/12304_1678801214413/bin/npm
1 info using npm@9.6.1
2 info using node@v18.15.0
3 timing npm:load:whichnode Completed in 1ms
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 0ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 0ms
8 timing config:load:env Completed in 1ms
9 info found workspace root at /Users/jpetrillo/Documents/Projects/with-npm
10 timing config:load:file:/Users/jpetrillo/Documents/Projects/with-npm/.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 1ms
17 timing config:load Completed in 6ms
18 timing npm:load:configload Completed in 6ms
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 2ms
25 timing npm:load:display Completed in 2ms
26 verbose logfile logs-max:10 dir:/Users/jpetrillo/.npm/_logs/2023-03-14T13_40_45_696Z-
27 verbose logfile /Users/jpetrillo/.npm/_logs/2023-03-14T13_40_45_696Z-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 16ms
32 timing command:config Completed in 1ms
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/with-npm/apps/latest
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 22ms
42 verbose code 1
43 error A complete log of this run can be found in:
43 error     /Users/jpetrillo/.npm/_logs/2023-03-14T13_40_45_696Z-debug-0.log
nathanhammond commented 1 year ago

npm config get registry

nathanhammond commented 1 year ago

So: I don't know who is making that call, but it does not appear to be next, and it isn't turbo. My current hypothesis is fnm. Further, I suspect that if you add a .npmrc file and set a registry value in it that the error would go away.

joepetrillo commented 1 year ago

Interesting! I am no expert in this, but was leaning towards it being next by intuition since it only happens after version 13.1.6. fnm is my node version manager, so that could be playing a role.

Also, it is probably worth mentioning that this only happens when running the dev server. Building does not throw this error.

Thanks for looking into it, at least we ruled out turbo.

joepetrillo commented 1 year ago

Sorry for the spam, but also want to mention here that I just tried running a fresh 13.2.4 nextjs app standalone (not using turbo or workspaces) and I am not seeing the error thrown anywhere.

This error happens when a nextjs (versions after 13.1.6) dev server runs in an npm workspace.

ifeltsweet commented 1 year ago

We run into the exact same issue but we are using n.

connerdassen commented 1 year ago

I run into the same issue when creating a completely empty repo using npx create-turbo@latest my_repo and running npm run dev.

edarioq commented 1 year ago

Same error using "turbo": "^1.9.3" "packageManager": "npm@9.5.1", and using node -v v18.16.0

iDVB commented 1 year ago

Also getting this same error with:

nx: 16.2.1
next: 13.3.0
pnpm: 7.11.0

We have workspaces setup in the package.json and in the pnpm-workspace.yaml

tounsoo commented 1 year ago

Same error here as well:

npm: 9.5.1
next: 13.4.0
turbo: 1.10.3
michaelangeloio commented 1 year ago

same error as well

SaavanNanavati commented 1 year ago

same

fasani-tx commented 1 year ago

same

ayothealoko commented 1 year ago

use npx next telemetry disable

from https://github.com/vercel/next.js/issues/47121#issuecomment-1499044345

EddyPBR commented 1 year ago

use npx next telemetry disable

from vercel/next.js#47121 (comment)

definitely resolved xD

fillippeprata commented 1 year ago

use npx next telemetry disable

from vercel/next.js#47121 (comment)

Perfect! Thank you very much :)

hunterchristian commented 11 months ago

Still seeing this error while using next@13.4.12 with a monorepo folder structure that leverages NPM workspaces. Also, npx next telemetry disable doesn't resolve the issue. @nathanhammond is it possible to reopen this?

I had to downgrade to next@13.1.6 to get my project to deploy.

la-leche commented 11 months ago

Guys, i've solved it!

Be loyal to your package manager: for npm: npx storybook@latest init --package-manager=npm for yarn: yarn dlx storybook@latest init --package-manager=yarn for pnpm: pnpm exec storybook@latest init --package-manager=pnpm

oste commented 9 months ago

npx next telemetry disable worked for me

ankitwaware commented 5 months ago

npx next telemetry disable worked for me https://nextjs.org/telemetry

jarrodmedrano commented 5 months ago

Disabling telemetry worked for me, but if I open another tab in a differnt folder location, I get the same error.

Aryan-Goel7 commented 3 months ago

npx next telemetry disable worked for me

da1z commented 3 months ago

also disabled turbo npx turbo telemetry disable

sahiwl commented 1 month ago

use npx next telemetry disable

from vercel/next.js#47121 (comment)

not helpful enough, even though no error occurs, npm run build starts the local dev server but is stuck on compiling on "turbo": "^2.0.11" "next": "15.0.0-rc.0" "packageManager": "npm@10.2.4"


image

Harsh3341 commented 4 weeks ago

Hey @sahiwl do you find any solution? I am facing the same issue as you (stuck in compiling).

sahiwl commented 4 weeks ago

Hey @sahiwl do you find any solution? I am facing the same issue as you (stuck in compiling).

glad to hear that im not the only one stuck with it, didn't found a solution yet. But I tried reproducing turborepo by npm create-turbo@latest in another directory (folder) and it worked!! Again - this isn't a solution, but another way to simply avoid it.
but you have to run npx next telemetry disable once, before running the local server. :)

ss- image

Harsh3341 commented 4 weeks ago

I have got a temporary solution, it might be caused by the turbopack so just remove the --turbo in package.json from the web and doc app