Vue3 CLI keeps asking about slow internet connection
P粉127901279
2023-09-04 13:16:33
<p>During the E2E testing process, I automatically installed Vue3 through the Vue CLI. The exact command is: </p>
<pre class="brush:php;toolbar:false;">npx --yes @vue/cli create vue3 --packageManager npm -n -i '{"useConfigFiles":true,"plugins":{ "@vue/cli-plugin-babel":{},"@vue/cli-plugin-typescript":{"classComponent":false,"useTsWithBabel":true},"@vue/cli- plugin-pwa":{},"@vue/cli-plugin-router":{"historyMode":true},"@vue/cli-plugin-vuex":{},"@vue/cli -plugin-eslint":{"config":"prettier","lintOn":["save"]}},"vueVersion":"3"}'</pre>
<p>The problem is that during this process, this problem keeps appearing: </p>
<pre class="brush:php;toolbar:false;">? Your connection to the default yarn registry seems to be slow.
Use https://registry.npmmirror.com for faster installation? (Y/n)</pre>
<p>The build failed because it is waiting for input. How can I cancel this prompt? </p>
I found the solution by looking at the Vue CLI source code. If you run the create command with registry parameters, you can set the environment variable VUE_CLI_TEST to avoid this prompt. Since I don't know what other effects setting this variable has, I ran it using a registry command. This is the code in src,
shouldUseTaobao
is the function responsible for the prompt: