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

npm init next-app creates a project that uses yarn #10647

Closed
pjaws opened this issue Feb 23, 2020 · 15 comments
Closed

npm init next-app creates a project that uses yarn #10647

pjaws opened this issue Feb 23, 2020 · 15 comments

Comments

@pjaws
Copy link
Contributor

pjaws commented Feb 23, 2020

Bug report

Describe the bug

Running npm init next-app creates a new Next.js project that uses Yarn, rather than npm. Given, the fact that I'm using npm to create the project, and the docs offer two options for getting started, one with npm and one with Yarn, this is completely unexpected behavior.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Read getting started docs
  2. Choose the npm option
  3. Run npm init next-app
  4. Get a project that uses Yarn

Expected behavior

It should create a project that uses npm for package management.

Here ya go, Tim!

@timneutkens
Copy link
Member

Already answered as per #10642 (comment)

This is expected behavior as you have yarn installed.

@pjaws
Copy link
Contributor Author

pjaws commented Feb 24, 2020 via email

@timneutkens
Copy link
Member

timneutkens commented Feb 24, 2020

@lfades let's update the docs to just mention npx.

@timneutkens
Copy link
Member

How could you possibly think that running npm init would create a project
with yarn?

I'm saying it's expected behavior and implemented this way by design, here's the yarn check:
https://github.com/zeit/next.js/blob/canary/packages/create-next-app/index.ts#L101

@pjaws
Copy link
Contributor Author

pjaws commented Feb 24, 2020 via email

@nkovacic
Copy link

nkovacic commented Mar 15, 2020

I also agree with @pjaws. Even if we have have yarn installed, create-next-app should have a switch to use npm instead of yarn if its detected.

@Janpot
Copy link
Contributor

Janpot commented Apr 3, 2020

FYI: Both npm and yarn should set an environment variable npm_execpath. Maybe that can be checked before the installation check to pick the right package manager? (I know it works on run, I'm not sure about init)

@timneutkens
Copy link
Member

timneutkens commented Apr 5, 2020

@tsriram did some investigation into how to detect npm here: #11628 (comment)

Happy to take in a PR as mentioned in that issue 👍

@tsriram
Copy link
Contributor

tsriram commented Apr 7, 2020

This should be fixed in #11683. I guess this issue can be closed once the new version is published.

@onomated
Copy link

@tsriram is there anyway to fix this in existing codebases?

@vschoener
Copy link

Just run into the same issue today and was surprised next install by using yarn instead of npm.

Doc says:

npm init next-app
# or
yarn create next-app

So can you explain (or fix the documentation) because I'm really lost.

@mbrookson
Copy link

Anyone who comes here, I don't think it's well documented but I found you can install with npm using the --use-npm flag.

e.g.

npx create-next-app my-app --use-npm

# or 

npm init next-app my-app --use-npm

Hope this helps 🙂

kodiakhq bot pushed a commit that referenced this issue Oct 13, 2020
Related issue: #10647 (comment)

Sometimes we have both Yarn and NPM installed and want to explicitly bootstrap an app with the CLI using NPM. Having this flag documented could help people understand the package manager behavior and select NPM if that's their preference.
@vercel vercel deleted a comment from yardz Nov 18, 2020
@Timer
Copy link
Member

Timer commented Nov 18, 2020

FYI running npm init with npm v7 will no longer use Yarn.

@yardz

This comment has been minimized.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

12 participants