首页 > 其他分享 >npm安装@vue/cli报错原因之一

npm安装@vue/cli报错原因之一

时间:2023-02-27 16:02:04浏览次数:61  
标签:npm node vue ERR Python 报错 gyp find

@

目录

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

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

    npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
    npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
    npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
    npm WARN deprecated [email protected]: this library is no longer supported
    npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
    npm WARN deprecated [email protected]: 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/[email protected]: Moved to 'npm install @sideway/address'
    npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
    npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
    npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi'
    npm WARN deprecated [email protected]: 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\炳烛夜已深\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\utf-8-validate
    npm ERR! command failed
    npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using [email protected]
    npm ERR! gyp info using [email protected] | 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\����ҹ����\AppData\Local\Programs\Python\Python37\python.exe"
    npm ERR! gyp ERR! find Python - "C:\Users\����ҹ����\AppData\Local\Programs\Python\Python37\python.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:\Python37\python.exe
    npm ERR! gyp ERR! find Python - "C:\Python37\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Python27\python.exe
    npm ERR! gyp ERR! find Python - "C:\Python27\python.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\����ҹ����\AppData\Local\Programs\Python\Python37\python.exe"
    npm ERR! gyp ERR! find Python - "C:\Users\����ҹ����\AppData\Local\Programs\Python\Python37\python.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:\Path\To\python.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:\Path\To\python.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:\SoftWare\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:302:47)
    npm ERR! gyp ERR! stack     at PythonFinder.runChecks (D:\SoftWare\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
    npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\SoftWare\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:220:16)
    npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (D:\SoftWare\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-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 one rrorNT (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\炳烛夜已深\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\utf-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\炳烛夜已深\AppData\Local\npm-cache\_logs\2021-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\炳烛夜已深\AppData\Local\npm-cache\_logs\2021-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\炳烛夜已深\AppData\Local\npm-cache\_logs\2021-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的安装与使用
    希望这篇笔记能够帮助到你

    标签:npm,node,vue,ERR,Python,报错,gyp,find
    From: https://www.cnblogs.com/beiChengBh/p/17152665.html

    相关文章

    • vue 运行步骤(使用cnpm)
      运行教程首先,列出来我们需要的东西:node.js环境(npm包管理器)vue-cli脚手架构建工具cnpmnpm的淘宝镜像从node.js官网下载并安装node,安装过程很简单,一路“下一步”就可以......
    • vscode跟踪vue代码方法
      首先安装插件同时打开上面的右边的齿轮图标,就是打开文件launch.json{//UseIntelliSensetolearnaboutpossibleattributes.//Hovertoviewdescriptionsof......
    • vue中解决一个部门不能选择的问题
      问题如下:就是在提交流程进行表单申请的时候,上面按用户选择的时候出现下面界面 结果最下面两个用户与按钮都按不了,不知道是什么原因。后来跟踪发现下面问题这个层面上面都......
    • vuex中commit和dispatch的区别
      一直都没整明白commit和dispath的区别,今天总算整明白了1、commit和dispatch的区别commit和dispatch的区别在于commit是提交mutatious的同步操作,dispatch是分发actions的......
    • Vue虚拟dom是如何被创建的
      先来看生成虚拟dom的入口文件:...import{parse}from'./parser/index'import{optimize}from'./optimizer'import{generate}from'./codegen/inde......
    • 2023前端一面vue面试题合集
      函数式组件优势和原理函数组件的特点函数式组件需要在声明组件是指定functional:true不需要实例化,所以没有this,this通过render函数的第二个参数context来代替没有生......
    • Vue组件是怎样挂载的
      我们先来关注一下$mount是实现什么功能的吧:我们打开源码路径core/instance/init.js:exportfunctioninitMixin(Vue:Class<Component>){......initLifec......
    • 腾讯前端二面常考vue面试题(附答案)
      虚拟DOM真的比真实DOM性能好吗首次渲染大量DOM时,由于多了一层虚拟DOM的计算,会比innerHTML插入慢。正如它能保证性能下限,在真实DOM操作的时候进行针对性的优化时,还是更快......
    • VUE里的find与filter使用与区别
      一、find方法(返回符合条件的第一个元素如果没有符合条件的返回undefined)findIndex方法(返回符合条件的第一个元素位置如果没有符合条件的返回-1)比如:constmodeler=th......
    • VUE里父组件与子组件的交互操作
          在开发vue前端项目时,经常会遇到父组件与子组件之间的相互操作,比如有时候父组件需要知道子组件的触发事件,以便对这个触发事件进行响应,同时附组件也要传递数据给子......