uniapp项目初始化时报gyp ERR

2023-10-07 13:28

本文主要是介绍uniapp项目初始化时报gyp ERR,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

电脑重装后,安装了node 18.16.1-x64,编写后端代码时都没遇到什么问题。

uniapp项目初始化时报gyp ERR,具体报错如下:

npm ERR! code 1
npm ERR! path D:\postman\hksvn\project\uniapp*\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: D:\Program Files\nodejs\node.exe D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli ‘D:\Program Files\nodejs\node.exe’,
npm ERR! gyp verb cli 'D:\postman\hksvn\project\uniapp\\node_modules\node-gyp\bin\node-gyp.js’,
npm ERR! gyp verb cli ‘rebuild’,
npm ERR! gyp verb cli ‘–verbose’,
npm ERR! gyp verb cli ‘–libsass_ext=’,
npm ERR! gyp verb cli ‘–libsass_cflags=’,
npm ERR! gyp verb cli ‘–libsass_ldflags=’,
npm ERR! gyp verb cli ‘–libsass_library=’
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@18.16.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing “build” directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if “python3” can be used
npm ERR! gyp verb find Python - executing “python3” to get executable path
npm ERR! gyp verb find Python - “python3” is not in PATH or produced an error
npm ERR! gyp verb find Python checking if “python” can be used
npm ERR! gyp verb find Python - executing “python” to get executable path
npm ERR! gyp verb find Python - “python” is not in PATH or produced an error
npm ERR! gyp verb find Python checking if “python2” can be used
npm ERR! gyp verb find Python - executing “python2” to get executable path
npm ERR! gyp verb find Python - “python2” is not in PATH or produced an error
npm ERR! gyp verb find Python checking if Python is C:\Python37\python.exe
npm ERR! gyp verb find Python - executing “C:\Python37\python.exe” to get version
npm ERR! gyp verb find Python - “C:\Python37\python.exe” could not be run
npm ERR! gyp verb find Python checking if Python is C:\Python27\python.exe
npm ERR! gyp verb find Python - executing “C:\Python27\python.exe” to get version
npm ERR! gyp verb find Python - “C:\Python27\python.exe” could not be run
npm ERR! gyp verb find Python checking if the py launcher can be used to find Python
npm ERR! gyp verb find Python - executing “py.exe” to get Python executable path
npm ERR! gyp verb find Python - “py.exe” is not in PATH or produced an error
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 - “python” is not in PATH or produced an error
npm 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 - “py.exe” is not in PATH or produced an error
npm 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:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-python.js:302:47)
npm ERR! gyp ERR! stack at PythonFinder.runChecks (D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-python.js:136:21)
npm ERR! gyp ERR! stack at PythonFinder. (D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-python.js:200:18)
npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-python.js:266:16)
npm ERR! gyp ERR! stack at exithandler (node:child_process:427:5)
npm ERR! gyp ERR! stack at ChildProcess.errorhandler (node:child_process:439:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:289:12)
npm ERR! gyp ERR! stack at onErrorNT (node:internal/child_process:476:16)
npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command “D:\Program Files\nodejs\node.exe” "D:\postman\hksvn\project\uniapp\
\node_modules\node-gyp\bin\node-gyp.js" “rebuild” “–verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
npm ERR! gyp ERR! cwd D:\postman\hksvn\project\uniapp*
****\node_modules\node-sass
npm ERR! gyp ERR! node -v v18.16.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

原来以为是没有安装python2,安装之后还是报错,这次报找不到VS2013

npm ERR! code 1
npm ERR! path D:\postman\hksvn\project\uniapp*\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: D:\Program Files\nodejs\node.exe D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli ‘D:\Program Files\nodejs\node.exe’,
npm ERR! gyp verb cli 'D:\postman\hksvn\project\uniapp\\node_modules\node-gyp\bin\node-gyp.js’,
npm ERR! gyp verb cli ‘rebuild’,
npm ERR! gyp verb cli ‘–verbose’,
npm ERR! gyp verb cli ‘–libsass_ext=’,
npm ERR! gyp verb cli ‘–libsass_cflags=’,
npm ERR! gyp verb cli ‘–libsass_ldflags=’,
npm ERR! gyp verb cli ‘–libsass_library=’
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@18.16.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing “build” directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if “python3” can be used
npm ERR! gyp verb find Python - executing “python3” to get executable path
npm ERR! gyp verb find Python - “python3” is not in PATH or produced an error
npm ERR! gyp verb find Python checking if “python” can be used
npm ERR! gyp verb find Python - executing “python” to get executable path
npm ERR! gyp verb find Python - executable path is “C:\Python27\python.exe”
npm ERR! gyp verb find Python - executing “C:\Python27\python.exe” to get version
npm ERR! gyp verb find Python - version is “2.7.18”
npm ERR! gyp info find Python using Python version 2.7.18 found at “C:\Python27\python.exe”
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 18.16.1
npm ERR! gyp verb command install [ ‘18.16.1’ ]
npm ERR! gyp verb install input version string “18.16.1”
npm ERR! gyp verb install installing version: 18.16.1
npm ERR! gyp verb install --ensure was passed, so won’t reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check “installVersion”
npm ERR! gyp verb got “installVersion” 9
npm ERR! gyp verb needs “installVersion” 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 18.16.1
npm ERR! gyp verb build dir attempting to create “build” dir: D:\postman\hksvn\project\uniapp*
\node_modules\node-sass\build
npm ERR! gyp verb build dir “build” dir needed to be created? D:\postman\hksvn\project\uniapp*
\node_modules\node-sass\build
npm ERR! gyp verb find VS msvs_version not set from command line or npm config
npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with ‘–loglevel silly’ for more details
npm ERR! gyp verb find VS looking for Visual Studio 2015
npm ERR! gyp verb find VS - not found
npm ERR! gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with ‘–loglevel silly’ for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the “Desktop development with C++” workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp ERR! stack at D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-visualstudio.js:74:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
npm ERR! gyp ERR! stack at D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-visualstudio.js:70:14
npm ERR! gyp ERR! stack at D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\find-visualstudio.js:372:16
npm ERR! gyp ERR! stack at D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at D:\postman\hksvn\project\uniapp*
\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:427:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command “D:\Program Files\nodejs\node.exe” "D:\postman\hksvn\project\uniapp\
\node_modules\node-gyp\bin\node-gyp.js" “rebuild” “–verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
npm ERR! gyp ERR! cwd D:\postman\hksvn\project\uniapp*
\node_modules\node-sass
npm ERR! gyp ERR! node -v v18.16.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

估计是当前node的版本与node-gyp对应不上。卸载node v18.16.1,下载node v16.20.2-x64并安装。

查看node版本:node -v

v16.20.2

查看npm版本:npm -v

8.19.4

查看npm配置信息(里面包含了仓储和缓存路径的默认位置):npm config ls

; "builtin" config from D:\Program Files\nodejs\node_modules\npm\npmrc; prefix = "C:\\Users\\Administrator\\AppData\\Roaming\\npm" ; overridden by user; "user" config from C:\Users\Administrator\.npmrccache = "D:\\Program Files\\nodejs\\node_modules\\node_cache"
prefix = "D:\\Program Files\\nodejs\\node_modules\\node_global"; node bin location = D:\Program Files\nodejs\node.exe
; node version = v16.20.2
; npm local prefix = D:\Program Files\nodejs
; npm version = 8.19.4
; cwd = D:\Program Files\nodejs\node_modules
; HOME = C:\Users\Administrator
; Run `npm config ls -l` to show all defaults.

cache和prefix是之前设置过的,可以通过以下命令修改

修改prefix的值

npm config set prefix 【全局仓库地址】(注意路径\要用\)
修改cache的值:npm config set cache【全局缓存地址】(注意路径\要用\)

修改完成后再用:npm config ls 查看即可

npm config set registry https://registry.npmmirror.com/

npm config get registry
https://registry.npmmirror.com/

npm config ls

; "builtin" config from D:\Program Files\nodejs\node_modules\npm\npmrc; prefix = "C:\\Users\\Administrator\\AppData\\Roaming\\npm" ; overridden by user; "user" config from C:\Users\Administrator\.npmrccache = "D:\\Program Files\\nodejs\\node_modules\\node_cache"
prefix = "D:\\Program Files\\nodejs\\node_modules\\node_global"
registry = "https://registry.npmmirror.com/"; node bin location = D:\Program Files\nodejs\node.exe
; node version = v16.20.2
; npm local prefix = D:\Program Files\nodejs
; npm version = 8.19.4
; cwd = D:\Program Files\nodejs\node_modules
; HOME = C:\Users\Administrator
; Run `npm config ls -l` to show all defaults.

再到uniapp项目中运行npm i,顺利完成。

这篇关于uniapp项目初始化时报gyp ERR的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/158045

相关文章

JVM 的类初始化机制

前言 当你在 Java 程序中new对象时,有没有考虑过 JVM 是如何把静态的字节码(byte code)转化为运行时对象的呢,这个问题看似简单,但清楚的同学相信也不会太多,这篇文章首先介绍 JVM 类初始化的机制,然后给出几个易出错的实例来分析,帮助大家更好理解这个知识点。 JVM 将字节码转化为运行时对象分为三个阶段,分别是:loading 、Linking、initialization

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

如何用Docker运行Django项目

本章教程,介绍如何用Docker创建一个Django,并运行能够访问。 一、拉取镜像 这里我们使用python3.11版本的docker镜像 docker pull python:3.11 二、运行容器 这里我们将容器内部的8080端口,映射到宿主机的80端口上。 docker run -itd --name python311 -p

在cscode中通过maven创建java项目

在cscode中创建java项目 可以通过博客完成maven的导入 建立maven项目 使用快捷键 Ctrl + Shift + P 建立一个 Maven 项目 1 Ctrl + Shift + P 打开输入框2 输入 "> java create"3 选择 maven4 选择 No Archetype5 输入 域名6 输入项目名称7 建立一个文件目录存放项目,文件名一般为项目名8 确定

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧

c++的初始化列表与const成员

初始化列表与const成员 const成员 使用const修饰的类、结构、联合的成员变量,在类对象创建完成前一定要初始化。 不能在构造函数中初始化const成员,因为执行构造函数时,类对象已经创建完成,只有类对象创建完成才能调用成员函数,构造函数虽然特殊但也是成员函数。 在定义const成员时进行初始化,该语法只有在C11语法标准下才支持。 初始化列表 在构造函数小括号后面,主要用于给

SpringBoot项目是如何启动

启动步骤 概念 运行main方法,初始化SpringApplication 从spring.factories读取listener ApplicationContentInitializer运行run方法读取环境变量,配置信息创建SpringApplication上下文预初始化上下文,将启动类作为配置类进行读取调用 refresh 加载 IOC容器,加载所有的自动配置类,创建容器在这个过程

Maven创建项目中的groupId, artifactId, 和 version的意思

文章目录 groupIdartifactIdversionname groupId 定义:groupId 是 Maven 项目坐标的第一个部分,它通常表示项目的组织或公司的域名反转写法。例如,如果你为公司 example.com 开发软件,groupId 可能是 com.example。作用:groupId 被用来组织和分组相关的 Maven artifacts,这样可以避免

2. 下载rknn-toolkit2项目

官网链接: https://github.com/airockchip/rknn-toolkit2 安装好git:[[1. Git的安装]] 下载项目: git clone https://github.com/airockchip/rknn-toolkit2.git 或者直接去github下载压缩文件,解压即可。

9.8javaweb项目总结

1.主界面用户信息显示 登录成功后,将用户信息存储在记录在 localStorage中,然后进入界面之前通过js来渲染主界面 存储用户信息 将用户信息渲染在主界面上,并且头像设置跳转,到个人资料界面 这里数据库中还没有设置相关信息 2.模糊查找 检测输入框是否有变更,有的话调用方法,进行查找 发送检测请求,然后接收的时候设置最多显示四个类似的搜索结果