关于人人开源框架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

相关推荐
Z***25802 小时前
React增强现实案例
前端·react.js·ar
IT_陈寒2 小时前
SpringBoot 3.2 性能优化全攻略:7个让你的应用提速50%的关键技巧
前端·人工智能·后端
GoFly开发者2 小时前
使用AES加解密在vue3前端加密、Golang后端解密实战教程(后端框架可以为Gin、Goframe等框架使用)
vue.js·aes加密vue·aes解密go
普通码农3 小时前
Vue-Konva 使用(缩放 / 还原 / 拖动) 示例
前端·javascript·vue.js
renxhui3 小时前
Flutter 布局 ↔ Android XML 布局 对照表(含常用属性)
前端
俺叫啥好嘞3 小时前
日志输出配置
java·服务器·前端
一 乐3 小时前
运动会|基于SpingBoot+vue的高校体育运动会管理系统(源码+数据库+文档)
java·前端·javascript·数据库·vue.js·学习·springboot
X_hope3 小时前
巧妙浏览器事件监听API:addEventListener的第三个参数
前端·javascript
極光未晚3 小时前
Node.js的"老伙计":Express框架入门记
前端·node.js