question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using npx to opt-out of telemetry when using yarn pnp will fail

See original GitHub issue

See original bug report below.

The page https://nextjs.org/telemetry suggest that telemetry can be disabled using npx next telemetry disable in the root of a project. This is similar to running the next binary that’s present in node_modules directly.

When using Yarn PnP (which is default for Yarn 2), npx next telemetry disable is going to try to run next using npm, and without pnp resolution (read: it will look for node_modules when resolving requires, instead of the hoisted location on disk).

Solution

Update the documentation to have the yarn commands listed as well:

npx next telemetry disable

# Or when using yarn
yarn next telemetry disable

(note: yarn next is, in this case similar to npx next, but it’s not exactly the same. Something to keep in mind).


What version of Next.js are you using?

10.0.5

What version of Node.js are you using?

12.20.1

What operating system are you using?

Windows

Describe the Bug

See steps to reproduce.

When using Yarn 2, it’s impossible to opt-out of telemetry on a permanent basis, because (assumption) the tooling is looking for react and react-dom in the non-pnp node_modules location.

It then continues giving an erroneous non-actionable error:

The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react'
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react-dom'
Cannot find module 'react'

After this occurs, it can be resolved by switching to Yarn 1:

yarn set version classic
yarn install

npx next telemetry disable

The expected behaviour is then observed.

Expected Behavior

$ npx next telemetry disable
Your preference has been saved.

Status: Disabled

You have opted-out of Next.js' anonymous telemetry program.
No data will be collected from your machine.
Learn more: https://nextjs.org/telemetry

To Reproduce

Following these steps, but then with --use-yarn.

npx create-next-app nextjs-blog --use-yarn --example "https://github.com/vercel/next-learn-starter/tree/master/learn-starter"

yarn set version berry
yarn install

Afterwards

npx next telemetry disable

Happy to run any more commands, but I think I’ve pointed out where I assume this error lies.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
amandeepmittalcommented, Apr 8, 2022

@SleeplessByte, we pushed changes to the docs. They will be up to date in the next release 🙏

1reaction
Timercommented, Jan 29, 2021

Oh, it seems our website is still closed source! @leerob can you please update this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plug'n'Play | Yarn - Package Manager
To address this problem, Yarn ships with a "loose" mode which will cause the PnP linker to work in tandem with the node-modules...
Read more >
Yarn 3.0 - Hacker News
I used to use yarn all the time until I tried pnpm. The speed is amazing, and as a traveler I love that...
Read more >
No Next.js version could be detected in your project. Make sure
I'm trying to deploy a project with yarn workspaces to ZEIT Now. I'm getting an error message that the module I'm trying to...
Read more >
Gatsby Changelog | 5.3.0
You might have run into an error like this while using Gatsby: ... Executing npm init gatsby -ts or npx create-gatsby -ts will...
Read more >
Toptout
Entered data will not be sent to the telemetry service. Use methods described below to opt-out of this telemetry channel. 1. Set environment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found