vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

cli beta.15 Ui-based project creation manually sets the npm registry to https://registry.npm.taobao.org for some of the npm install commands #1433

Open lyonsbp opened 6 years ago

lyonsbp commented 6 years ago

Version

3.0.0-beta.15

Reproduction link

https://github.com/vuejs/vue-cli

Steps to reproduce

Create a new project by running vue ui and following the prompts. Choose manual preset, then include Router, SCSS support, Unit tests, and eslint. Allow dependencies to install, which will run an npm install command that against the https://registry.npm.taobao.org mirror

What is expected?

Expected: project will be created with all dependencies installed correctly

What is actually happening?

Let me say first I know this is an abnormal issue that is against the rules, I just really did not think this behavior is intentional, and since the issue is based around a physical geographic separation I cannot provide a reliable link for anyone in the world to reproduce.

Actual: the command npm install --loglevel error --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist is executed, which forces npm to use the taobao registry. Since this server is in China, and I am in the US, I eventually get an invalid checksum on a package. I know this is an odd issue to report, since it is up to chance, but I have tried this over 6 times throughout the day to the same error. I tried all the common solutions like running npm cache clean --force.

I understand this is not a vue.js problem, but I assumed this was being set by mistake. Is there a reason the npm install command is forcing the registry to use the Chinese server?


gyp ERR! System Darwin 17.5.0 gyp ERR! command "/usr/local/bin/node" "/Users/brandon/mcity/mcity-vue-frontend/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /Users/brandon/mcity/mcity-vue-frontend/node_modules/node-sass gyp ERR! node -v v8.9.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok Build failed with error code: 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.9.0 postinstall: node scripts/build.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass@4.9.0 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/brandon/.npm/_logs/2018-06-01T20_28_41_638Z-debug.log command failed: npm install --loglevel error --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist

lyonsbp commented 6 years ago

Want to make it known that I also tried after manually setting the npm registry with npm config set registry https://registry.npmjs.org/

lyonsbp commented 6 years ago

Posting link to the full npm debug log: https://pastebin.com/TF2c7m0P

yyx990803 commented 6 years ago

This probably happened when the npm registry itself was having a slow response so the CLI inferred it would be faster to use the Taobao mirror... however, there should be a CLI prompt asking you whether that is ok. That seems to be missed when creating from UI? /cc @Akryum

You can manually turn this behavior off by editing ~/.vuerc and set useTaobaoRegistry to false.

lml2014 commented 6 years ago

above method is useful. I use vue create xx alway has error, and I set npm registry not well, It alway has error. ERROR command failed: npm install --loglevel error --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist according to the above method,I set useTaobaoRegistry=false on vuerc file, it work well.

daingreen commented 6 years ago

it actually worked! thanks for useful guide.

thinh105 commented 4 years ago

This probably happened when the npm registry itself was having a slow response so the CLI inferred it would be faster to use the Taobao mirror... however, there should be a CLI prompt asking you whether that is ok. That seems to be missed when creating from UI? /cc @Akryum

You can manually turn this behavior off by editing ~/.vuerc and set useTaobaoRegistry to false.

Still don't see the CLI prompt ask users about that,

It took me an hour to figure out what happened when the NPM package change to Taobao mirror

Please fix that,

Thanks

hiendv commented 4 years ago

Regarding the connection speed, I think it's okay to switch registry with consent from users. But for me, I'm not really comfortable if vue tries to make that registry global. S̶o̶ ̶i̶n̶s̶t̶e̶a̶d̶ ̶o̶f̶ ̶r̶u̶n̶n̶i̶n̶g̶ t̶h̶i̶s̶ ̶c̶o̶m̶m̶a̶n̶d̶, h̶o̶w̶ ̶a̶b̶o̶u̶t̶ ̶s̶e̶t̶t̶i̶n̶g̶ ̶t̶h̶e̶ ̶r̶e̶g̶i̶s̶t̶r̶y̶ ̶p̶e̶r̶ ̶p̶r̶o̶j̶e̶c̶t̶ ̶u̶s̶i̶n̶g̶ .n̶p̶m̶r̶c̶ f̶i̶l̶e̶?

Update: I read the source again and my above comment is irrelevant because it's actually "getting" not "setting" (I was day-dreaming :rofl:). I also tried to re-produce "global" issue but its impossible for me. @vue/cli saves shouldUseTaobao into ~/.vuerc and use it for future @vue/cli tasks. The global npm registry remains untouched. Other npm install should not pick this registry. https://github.com/vuejs/vue-cli/blob/e2f00d2867269b411c7b1a7c703b7222a6185d84/packages/%40vue/cli/lib/util/ProjectPackageManager.js#L157-L164

So, @vue/cli works as expected I guess :+1:

haoqunjiang commented 4 years ago

Good advice! I'd love to do that in the next major.