关于人人开源框架renren-fast-vue前端npm install安装报错的问题解决方法

一、问题

我遇到的报错是node-sass包的问题,这个包要求本地环境使用python2.7,但是我的版本是python3。

报错信息如下:

复制代码
npm error code 1
npm error path D:\project\renren-test\renren-ui\node_modules\node-sass
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm error Building: D:\nvm4w\nodejs\node.exe D:\project\renren-test\renren-ui\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm error gyp info it worked if it ends with ok
npm error gyp verb cli [
npm error gyp verb cli   'D:\\nvm4w\\nodejs\\node.exe',
npm error gyp verb cli   'D:\\project\\renren-test\\renren-ui\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm error gyp verb cli   'rebuild',
npm error gyp verb cli   '--verbose',
npm error gyp verb cli   '--libsass_ext=',
npm error gyp verb cli   '--libsass_cflags=',
npm error gyp verb cli   '--libsass_ldflags=',
npm error gyp verb cli   '--libsass_library='
npm error gyp verb cli ]
npm error gyp info using node-gyp@3.8.0
npm error gyp info using node@25.2.1 | win32 | x64
npm error gyp verb command rebuild []
npm error gyp verb command clean []
npm error gyp verb clean removing "build" directory
npm error gyp verb command configure []
npm error gyp verb check python checking for Python executable "python2" in the PATH
npm error gyp verb `which` failed Error: not found: python2
npm error gyp verb `which` failed     at getNotFoundError (D:\project\renren-test\renren-ui\node_modules\which\which.js:13:12)
npm error gyp verb `which` failed     at F (D:\project\renren-test\renren-ui\node_modules\which\which.js:68:19)
npm error gyp verb `which` failed     at E (D:\project\renren-test\renren-ui\node_modules\which\which.js:80:29)
npm error gyp verb `which` failed     at D:\project\renren-test\renren-ui\node_modules\which\which.js:89:16
npm error gyp verb `which` failed     at D:\project\renren-test\renren-ui\node_modules\isexe\index.js:42:5
npm error gyp verb `which` failed     at D:\project\renren-test\renren-ui\node_modules\isexe\windows.js:36:5
npm error gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:190:21)
npm error gyp verb `which` failed  python2 Error: not found: python2
npm error gyp verb `which` failed     at getNotFoundError (D:\project\renren-test\renren-ui\node_modules\which\which.js:13:12)
npm error gyp verb `which` failed     at F (D:\project\renren-test\renren-ui\node_modules\which\which.js:68:19)
npm error gyp verb `which` failed     at E (D:\project\renren-test\renren-ui\node_modules\which\which.js:80:29)
npm error gyp verb `which` failed     at D:\project\renren-test\renren-ui\node_modules\which\which.js:89:16
npm error gyp verb `which` failed     at D:\project\renren-test\renren-ui\node_modules\isexe\index.js:42:5
npm error gyp verb `which` failed     at D:\project\renren-test\renren-ui\node_modules\isexe\windows.js:36:5
npm error gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:190:21) {
npm error gyp verb `which` failed   code: 'ENOENT'
npm error gyp verb `which` failed }
npm error gyp verb check python checking for Python executable "python" in the PATH
npm error gyp verb `which` succeeded python C:\Users\Lenovo\AppData\Local\Programs\Python\Python312\python.EXE
npm error (node:37480) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
npm error (Use `node --trace-deprecation ...` to show where the warning was created)
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Command failed: C:\Users\Lenovo\AppData\Local\Programs\Python\Python312\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm error gyp ERR! stack   File "<string>", line 1
npm error gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm error gyp ERR! stack                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm error gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm error gyp ERR! stack
npm error gyp ERR! stack     at genericNodeError (node:internal/errors:998:15)
npm error gyp ERR! stack     at wrappedFn (node:internal/errors:543:14)
npm error gyp ERR! stack     at ChildProcess.exithandler (node:child_process:417:12)
npm error gyp ERR! stack     at ChildProcess.emit (node:events:508:28)
npm error gyp ERR! stack     at maybeClose (node:internal/child_process:1085:16)
npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm error gyp ERR! System Windows_NT 10.0.26200
npm error gyp ERR! command "D:\\nvm4w\\nodejs\\node.exe" "D:\\project\\renren-test\\renren-ui\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm error gyp ERR! cwd D:\project\renren-test\renren-ui\node_modules\node-sass
npm error gyp ERR! node -v v25.2.1
npm error gyp ERR! node-gyp -v v3.8.0
npm error gyp ERR! not ok
npm error Build failed with error code: 1
npm error A complete log of this run can be found in: D:\nodejs\node_cache\_logs\2025-11-23T08_43_31_544Z-debug-0.log

讲真python2太老了我不想安装,因此我折腾了五六个小时才彻底解决这个问题。

二、我的解决方法

首先版本选择上使用14.21.3,我查到的资料中很多人都是在这个版本上成功的,建议直接用这个版本,少走弯路!!

https://nodejs.org/dist/v14.21.3/node-v14.21.3-x64.msi

在下载nodejs的时候我也用过nvm,但是我用它下载低版本的时候npm会出现下载失败的情况,因此我抛弃了nvm。

接下来是最关键的一步!!在报错后使用一下命令单独安装node-sass。

复制代码
npm install node-sass@npm:sass --ignore-scripts

这个命令是安装一个包名是 node-sass,但它的实际内容是 sass的文件,sass可以理解为一个高版本的node-sass的一个替代品。

这个命令在一些nodejs版本可能会失败,因此建议使用上述的版本。

三、结果

输入npm run serve运行项目,倒腾了好久,看见运行成功真的泪目了o(╥﹏╥)o

希望这篇文章可以对你有帮助,我也是翻了好久的帖子才解决的问题。

关键帮助网站

https://gitee.com/renrenio/renren-fast-vue/issues/ICGJ6N

安装nodejs方法

https://blog.csdn.net/yy1715713348/article/details/142741619?ops_request_misc=%257B%2522request%255Fid%2522%253A%252245b355eb5193fd63d9a8f7d528724aed%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=45b355eb5193fd63d9a8f7d528724aed&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-142741619-null-null.142^v102^pc_search_result_base1&utm_term=nodejs%E5%AE%89%E8%A3%85&spm=1018.2226.3001.4187

卸载nodejs

https://blog.csdn.net/weixin_46434152/article/details/129321926?ops_request_misc=&request_id=&biz_id=102&utm_term=nodejs%E5%8D%B8%E8%BD%BD&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-1-129321926.142^v102^pc_search_result_base1&spm=1018.2226.3001.4187

相关推荐
foundbug99911 分钟前
Modbus协议C语言实现(易于移植版本)
java·c语言·前端
Luna-player12 分钟前
在前端中list.map的用法
前端·数据结构·list
用户479492835691516 分钟前
面试官问 React Fiber,这一篇文章就够了
前端·javascript·react.js
LYFlied28 分钟前
【一句话概述】Webpack、Vite、Rollup 核心区别
前端·webpack·node.js·rollup·vite·打包·一句话概述
用户8417948145632 分钟前
vxe-table 实现滚动加载数据,无限加载数据教程
vue.js
reddingtons39 分钟前
PS 参考图像:线稿上色太慢?AI 3秒“喂”出精细厚涂
前端·人工智能·游戏·ui·aigc·游戏策划·游戏美术
一水鉴天41 分钟前
整体设计 定稿 之23+ dashboard.html 增加三层次动态记录体系仪表盘 之2 程序 (Q199 之2) (codebuddy)
开发语言·前端·javascript
刘发财43 分钟前
前端一行代码生成数千页PDF,dompdf.js新增分页功能
前端·typescript·开源
_请输入用户名1 小时前
Vue 3 源码项目结构详解
前端·vue.js
前端无涯1 小时前
Vue3---(2)setup
vue.js