首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >关于人人开源框架renren-fast-vue前端npm install安装报错的问题解决方法

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

作者头像
用户11935701
发布2025-12-16 09:11:28
发布2025-12-16 09:11:28
960
举报

一、问题

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

报错信息如下:

代码语言:javascript
复制
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。

代码语言:javascript
复制
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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-12-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、问题
  • 二、我的解决方法
  • 三、结果
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档