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

Latest version cannot create anything without yarn #3421

Closed
Phoscur opened this issue Feb 5, 2019 · 12 comments
Closed

Latest version cannot create anything without yarn #3421

Phoscur opened this issue Feb 5, 2019 · 12 comments
Labels
cannot reproduce We cannot reproduce the problem with the given information. More env information needed.

Comments

@Phoscur
Copy link

Phoscur commented Feb 5, 2019

Version

3.4.0

Environment info

Environment Info:

  System:
    OS: Linux 4.20 Fedora 29 (Workstation Edition) 29 (Workstation Edition)
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 10.14.1 - /usr/bin/node
    Yarn: Not Found
    npm: 6.4.1 - /usr/bin/npm
  Browsers:
    Chrome: 72.0.3626.81
    Firefox: 65.0
  npmGlobalPackages:
    @vue/cli: 3.3.0 (reverted, this one works while latest is broken)

Steps to reproduce

  1. use clean machine
  2. install node 10 with npm, no yarn
  3. npm i -g @vue/cli
  4. vue create hello

What is expected?

Wizard starts, asking for options e.g. which package manager to use.

What is actually happening?

Yarn is missing (although not needed), wizard and childprocess crash.

ERROR  Error: spawn yarn ENOENT
Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

Any attempts in forcing npm as a packageManager (via .vuerc) were futile, either returning the same error or this one:

ERROR  ~/.vuerc may be outdated. Please delete it and re-run vue-cli in manual mode.
@haoqunjiang
Copy link
Member

Can't reproduce.
Unless you've got yarnpkg installed but no yarn command presents, I don't see any code logic to produce such errors.

@haoqunjiang haoqunjiang added the cannot reproduce We cannot reproduce the problem with the given information. More env information needed. label Feb 5, 2019
@Phoscur
Copy link
Author

Phoscur commented Feb 6, 2019

Tried to reproduce again and failed (today was my third install of version 3.4.0).
CLI 3.4.0 now also let's me choose presets I have created with version 3.3.0.
Issue might be still reproducible with a clean machine. Or maybe I just had a bad download : /
closing.

@Phoscur Phoscur closed this as completed Feb 6, 2019
@SamuelEarl
Copy link

SamuelEarl commented Oct 17, 2019

I ran into a similar issue with a very similar error message, which I could not figure out for a long time. I wanted to record what I discovered in the hope that it could help someone in the future.

When I would create new Vue projects with vue create <project name> it would create a yarn.lock file, even though I was using npm. So I tried uninstalling Yarn and removing all necessary Yarn files to prevent this from happening. After uninstalling Yarn, I got a Error: spawn yarn ENOENT message in my terminal (very similar to the one shown above) and I could not create any Vue projects.

After trying a bunch of things, I reinstalled Yarn and everything worked again. I could see that Vue CLI was clearly creating projects with Yarn, but I didn't know why. And then I came across this post: #1300. I also read the documentation that explains the .vuerc file here: https://cli.vuejs.org/guide/creating-a-project.html#vue-create. That solved everything. I opened the ~/.vuerc file and set the package manager to npm and all is well now.

@karl93rus
Copy link

@SamuelEarl Thank you for the hint with .vuerc. That solved a problem!

@davidmeirlevy
Copy link

had the same issue.
i removed ~/.vuerc file, and now it works.

@anubhavcodes
Copy link

I had the same problem today. I had installed yarn before via npm and then removed it recently. npm list had only two packages.

don@don-mbp changemark % npm list -g --depth=0
/usr/local/lib
├── @vue/cli@4.1.2
└── npm@6.13.4

I checked ~/.vuerc and and some Vue CLI selected yarn as the package manager. It will be interesting to see how vuecli determines the package manager installed on the host.

removing the ~/.vuerc file fixed the problem for me.

@quriosapien
Copy link
Contributor

I had yarn installed through brew.
Uninstalling yarn and reinstalling it worked for me.

I guess in my case, I tampered some core files for node while I was switching between different versions of nodejs using nvm. In the process I modified some globally installed packages, which is where I guess, @vue/cli was tampered.

@hayashi-ay
Copy link

hayashi-ay commented Mar 10, 2020

I had the same problem and removing the .vuerc worked fine for me.

I'm using nodebrew for Node.js version manegement.
I had run vue create with v12.10.0 of node and it was okay that time. (I think I had installed yarn via npm.)
Then, I switched node version to v12.16.1 by nodebrew use v12.16.1 and run vue create.
The following error message shows up this time.

ERROR  Error: spawn yarn ENOENT
Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I removed the .vuerc:

{
  "useTaobaoRegistry": false,
  "packageManager": "yarn",
  "presets": {
    "default": {
      "useConfigFiles": false,
      "plugins": {
        "@vue/cli-plugin-babel": {},
        "@vue/cli-plugin-eslint": {
          "config": "airbnb",
          "lintOn": [
            "save"
          ]
        }
      }
    }
  }
}

and after vue create it became :

{
  "useTaobaoRegistry": true
}

@haoqunjiang
Copy link
Member

@hayashi-ay
An additional tip: if you are outside China, maybe useTaobaoRegistry: false works better for you.
We set this flag by pinging different registries on the first run. If it's set to true than a mirror registry inside China is used to install dependencies.
But the mirror is inside China so most other users won't benefit from it. So if you are not in China, I guess there's a misjudgment in the pinging process. Set it back to false can avoid potential issues in the future.

@hayashi-ay
Copy link

@sodatea thanks for explaining the useTaobaoRegistry. I'm in Japan, so I switched it to false.

@hayashi-ay
Copy link

@sodatea Hi there, I've just come up with three questions. Please let me know if it doesn't bother you.

  • why the mirror registry inside China is necessary?
  • what is the difference between the default and the mirror?
  • what kind of issue I may encounter if I set the option true?

I also glanced at the pinning process and found that the option is likely to be true in Japan because of the geographic factor.
Can I create PR about the modification of the process?

The output of pinning to the both registries is below. I found that the taobao registry win the promise race with a higly probability.

$ ping -c 10 registry.npmjs.org
PING registry.npmjs.org (104.16.19.35): 56 data bytes
64 bytes from 104.16.19.35: icmp_seq=0 ttl=56 time=14.654 ms
64 bytes from 104.16.19.35: icmp_seq=1 ttl=56 time=5.648 ms
64 bytes from 104.16.19.35: icmp_seq=2 ttl=56 time=8.810 ms
64 bytes from 104.16.19.35: icmp_seq=3 ttl=56 time=12.804 ms
64 bytes from 104.16.19.35: icmp_seq=4 ttl=56 time=13.898 ms
64 bytes from 104.16.19.35: icmp_seq=5 ttl=56 time=12.059 ms
64 bytes from 104.16.19.35: icmp_seq=6 ttl=56 time=7.670 ms
64 bytes from 104.16.19.35: icmp_seq=7 ttl=56 time=5.449 ms
64 bytes from 104.16.19.35: icmp_seq=8 ttl=56 time=5.936 ms
64 bytes from 104.16.19.35: icmp_seq=9 ttl=56 time=5.591 ms

--- registry.npmjs.org ping statistics ---
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 5.449/9.252/14.654/3.547 ms

$ ping -c 10 registry.npm.taobao.org
PING registry.npm.taobao.org.w.cdngslb.com (202.47.28.95): 56 data bytes
64 bytes from 202.47.28.95: icmp_seq=0 ttl=52 time=8.073 ms
64 bytes from 202.47.28.95: icmp_seq=1 ttl=52 time=13.499 ms
64 bytes from 202.47.28.95: icmp_seq=2 ttl=52 time=8.884 ms
64 bytes from 202.47.28.95: icmp_seq=3 ttl=52 time=7.240 ms
64 bytes from 202.47.28.95: icmp_seq=4 ttl=52 time=13.869 ms
64 bytes from 202.47.28.95: icmp_seq=5 ttl=52 time=18.765 ms
64 bytes from 202.47.28.95: icmp_seq=6 ttl=52 time=6.975 ms
64 bytes from 202.47.28.95: icmp_seq=7 ttl=52 time=13.956 ms
64 bytes from 202.47.28.95: icmp_seq=8 ttl=52 time=6.983 ms
64 bytes from 202.47.28.95: icmp_seq=9 ttl=52 time=7.068 ms

--- registry.npm.taobao.org.w.cdngslb.com ping statistics ---
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 6.975/10.531/18.765/3.953 ms

@haoqunjiang
Copy link
Member

haoqunjiang commented Mar 11, 2020

@hayashi-ay I guess because Japan is so close to China, the connectivity is fine. Then you'll be fine with either registry.

what kind of issue I may encounter if I set the option true?

In other countries, it may take too long to download from the mirror registry: #5144 #1385

  • why the mirror registry inside China is necessary?
  • what is the difference between the default and the mirror?

In China, home broadband users are likely to face QoS issues when accessing oversea servers. So downloading from the official npm registry may be slow unless you are using commercial broadband.

Besides, due to the GFW, many websites are not accessible in China including most Google servers (making chromedriver binary CDN inaccessible). I also believe that connection Amazon S3 storage (which hosts binary files for many npm packages) is throttled so that downloading is extremely slow.

When useTaobaoRegistry is set, Vue CLI will install dependencies with that mirror registry, and try to work around the binary downloading issue by setting environment variables. You can see the relevant code here: https://github.com/vuejs/vue-cli/blob/v4.2.3/packages/%40vue/cli/lib/util/ProjectPackageManager.js#L166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce We cannot reproduce the problem with the given information. More env information needed.
Projects
None yet
Development

No branches or pull requests

8 participants