栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

npm install -g @vue/cli报错

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

npm install -g @vue/cli报错

npm安装@vue/cli报错npm ERR! request to https://registry.npm.taobao.org/loglevel failed, reason: Socket timeout

最终解决方案为:使用cnpm下载vue-cli,下面是我的问题和解决方法,可以供你借鉴

起初安装过程中报错为这个

npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated graphql-extensions@0.15.0: The  API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.nAnd it will no longer receive updates.nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.nCheck out https://www.graphql-tools.com to learn what package you should use instead
npm ERR! code 1
npm ERR! path C:Users炳烛夜已深AppDataRoamingnpmnode_modules@vueclinode_modulesutf-8-validate
npm ERR! command failed
npm ERR! command C:WINDOWSsystem32cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@15.12.0 | win32 | x64
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - executable path is "C:Users����ҹ����AppDataLocalProgramsPythonPython37python.exe"
npm ERR! gyp ERR! find Python - "C:Users����ҹ����AppDataLocalProgramsPythonPython37python.exe" could not be runnpm ERR! gyp ERR! find Python checking if "python2" can be used
npm ERR! gyp ERR! find Python - "python2" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if Python is C:Python37python.exe
npm ERR! gyp ERR! find Python - "C:Python37python.exe" could not be run
npm ERR! gyp ERR! find Python checking if Python is C:Python27python.exe
npm ERR! gyp ERR! find Python - "C:Python27python.exe" could not be run
npm ERR! gyp ERR! find Python checking if the py launcher can be used to find Python
npm ERR! gyp ERR! find Python - executable path is "C:Users����ҹ����AppDataLocalProgramsPythonPython37python.exe"
npm ERR! gyp ERR! find Python - "C:Users����ҹ����AppDataLocalProgramsPythonPython37python.exe" could not be runnpm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="C:PathTopython.exe"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "C:PathTopython.exe"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (D:SoftWarenodejsnode_modulesnpmnode_modulesnode-gyplibfind-python.js:302:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (D:SoftWarenodejsnode_modulesnpmnode_modulesnode-gyplibfind-python.js:136:21)
npm ERR! gyp ERR! stack     at PythonFinder. (D:SoftWarenodejsnode_modulesnpmnode_modulesnode-gyplibfind-python.js:220:16)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (D:SoftWarenodejsnode_modulesnpmnode_modulesnode-gyplibfind-python.js:266:16)
npm ERR! gyp ERR! stack     at exithandler (node:child_process:333:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:345:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:369:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:480:16)
npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:81:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "D:\SoftWare\nodejs\node.exe" "D:\SoftWare\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:Users炳烛夜已深AppDataRoamingnpmnode_modules@vueclinode_modulesutf-8-validate
npm ERR! gyp ERR! node -v v15.12.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:Users炳烛夜已深AppDataLocalnpm-cache_logs2021-09-28T01_50_54_201Z-debug.log

C:Users炳烛夜已深>npm config set strict-ssl false

C:Users炳烛夜已深>npm config set strict-ssl true

C:Users炳烛夜已深>npm install -g @vue/cli
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! request to https://registry.npm.taobao.org/loglevel failed, reason: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     C:Users炳烛夜已深AppDataLocalnpm-cache_logs2021-09-28T01_53_39_921Z-debug.log

有说设置一下

npm config set strict-ssl false		// 就可以啦

不过还是报这样的错误,于是我重新设置回来

npm config set strict-ssl true		

再次下载,错误如下:

npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! request to https://registry.npm.taobao.org/loglevel failed, reason: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     C:Users炳烛夜已深AppDataLocalnpm-cache_logs2021-09-28T01_53_39_921Z-debug.log	

npm ERR! request to https://registry.npm.taobao.org/loglevel failed, reason: Socket timeout
主要原因就是:请求https://registry.npm.taobao.org/loglevel失败

原因找到啦,请求淘宝npm包镜像地址失败,因为我本人使用nrm,切换了npm下载包的镜像地址

C:Users炳烛夜已深>nrm ls

  npm -------- https://registry.npmjs.org/
  yarn ------- https://registry.yarnpkg.com/
  cnpm ------- http://r.cnpmjs.org/
* taobao ----- https://registry.npm.taobao.org/
  nj --------- https://registry.nodejitsu.com/
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/

看到这个错误原因,结合我在百度查找解决下载vue-cli的方法看到的一些方案,使用cnpm镜像网址下载vue-cli好像成功率更好,于是我果断切换npm下载包的镜像地址

nrm use cnpm

再次下载vue-cli

npm install -g @vue/cli

(虽然警告有很多,但是)下载成功

记录一下日常bug的解决方案,早知道就使用cnpm镜像地址下载啦

关于nrm的使用,大家可以看我的这个: nrm的安装与使用.
希望这篇文章能够帮助到你

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/275809.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号