renren-fast-vue无法运行相关问题解决办法n ./src/assets/scss/index.scss Module build failed: Error: ENOENT: no su

博客内容讲述了在尝试运行renren-fast-vue项目时遇到的模块构建失败错误,具体是由于node-sass模块找不到文件导致。作者分享了解决该问题的步骤,包括切换npm源到淘宝镜像、安装chromedriver时指定cdn地址、切换Node版本以及通过设置sass_binary_site来安装node-sass。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

in ./src/assets/scss/index.scss

Module build failed: Error: ENOENT: no such file or directory, scandir ‘C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\vendor’
at Object.fs.readdirSync (fs.js:861:3)
at Object.getInstalledBinaries (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\extensions.js:129:13)
at foundBinariesList (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\errors.js:20:15)
at foundBinaries (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\errors.js:15:5)
at Object.module.exports.missingBinary (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\errors.js:45:5)
at module.exports (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\binding.js:15:30)
at Object. (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\sass-loader\lib\loader.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:678:30)

@ ./src/assets/scss/index.scss 4:14-212 13:3-17:5 14:22-220
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8001 webpack/hot/dev-server babel-polyfill ./src/main.js

error in ./src/views/demo/ueditor.vue

Module build failed: Error: ENOENT: no such file or directory, scandir ‘C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\vendor’
at Object.fs.readdirSync (fs.js:861:3)
at Object.getInstalledBinaries (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\extensions.js:129:13)
at foundBinariesList (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\errors.js:20:15)
at foundBinaries (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\errors.js:15:5)
at Object.module.exports.missingBinary (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\errors.js:45:5)
at module.exports (C:\Users\xyy’s\Desktop\renren-fast-vue\node_modules\node-sass\lib\binding.js:15:30)

npm ERR! code 1 npm ERR! path D:\develop\frontEnd\yiye\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:\development\nodejs\node.exe D:\develop\frontEnd\yiye\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:\\development\\nodejs\\node.exe', npm ERR! gyp verb cli 'D:\\develop\\frontEnd\\yiye\\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@3.8.0 npm ERR! gyp info using node@16.20.2 | 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 check python checking for Python executable "python2" in the PATH npm ERR! gyp verb `which` failed Error: not found: python2 npm ERR! gyp verb `which` failed at getNotFoundError (D:\develop\frontEnd\yiye\node_modules\which\which.js:13:12) npm ERR! gyp verb `which` failed at F (D:\develop\frontEnd\yiye\node_modules\which\which.js:68:19) npm ERR! gyp verb `which` failed at E (D:\develop\frontEnd\yiye\node_modules\which\which.js:80:29) npm ERR! gyp verb `which` failed at D:\develop\frontEnd\yiye\node_modules\which\which.js:89:16 npm ERR! gyp verb `which` failed at D:\develop\frontEnd\yiye\node_modules\isexe\index.js:42:5 npm ERR! gyp verb `which` failed at D:\develop\frontEnd\yiye\node_modules\isexe\windows.js:36:5 npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:202:21) npm ERR! gyp verb `which` failed python2 Error: not found: python2 npm ERR! gyp verb `which` failed at getNotFoundError (D:\develop\frontEnd\yiye\node_modules\which\which.js:13:12) npm ERR! gyp verb `which` failed at F (D:\develop\frontEnd\yiye\node_modules\which\which.js:68:19) npm ERR! gyp verb `which` failed at E (D:\develop\frontEnd\yiye\node_modules\which\which.js:80:29) npm ERR! gyp verb `which` failed at D:\develop\frontEnd\yiye\node_modules\which\which.js:89:16 npm ERR! gyp verb `which` failed at D:\develop\frontEnd\yiye\node_modules\isexe\index.js:42:5 npm ERR! gyp verb `which` failed at D:\develop\frontEnd\yiye\node_modules\isexe\windows.js:36:5 npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:202:21) { npm ERR! gyp verb `which` failed code: 'ENOENT' npm ERR! gyp verb `which` failed } npm ERR! gyp verb check python checking for Python executable "python" in the PATH npm ERR! gyp verb `which` succeeded python D:\development\py\python.EXE npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Command failed: D:\development\py\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3]; npm ERR! gyp ERR! stack File "<string>", line 1 npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3]; npm ERR! gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? npm ERR! gyp ERR! stack npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:402:12) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1100:16) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) npm ERR! gyp ERR! System Windows_NT 10.0.26100 npm ERR! gyp ERR! command "D:\\development\\nodejs\\node.exe" "D:\\develop\\frontEnd\\yiye\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" npm ERR! gyp ERR! cwd D:\develop\frontEnd\yiye\node_modules\node-sass npm ERR! gyp ERR! node -v v16.20.2 npm ERR! gyp ERR! node-gyp -v v3.8.0 npm ERR! gyp ERR! not ok npm ERR! Build failed with error code: 1 npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\69536\AppData\Local\npm-cache\_logs\2025-05-21T03_23_17_531Z-debug-0.log如何解决
05-22
### 解决 `npm install node-sass` 出现的 `node-gyp` 错误 (Python 版本不兼容) 当在 Windows 上运行 `npm install node-sass` 时,如果出现如下错误提示: ``` gyp ERR! stack Error: Python executable "C:\Python27\python.EXE" is v2.7.18, which is not supported by gyp. gyp ERR! System Windows_NT 10.0.19043 gyp ERR! node -v v16.13.0 gyp ERR! node-gyp -v v8.4.1 ``` 这通常是因为 `node-gyp` 使用的 Python 版本不符合其需求。以下是详细的分析与解决方案。 --- #### **原因分析** 1. **Python 版本问题**: 当前 `node-gyp` 只支持特定版本的 Python。例如,`node-gyp@8.x` 要求使用 Python 3.x,而不是旧版的 Python 2.x[^5]。 2. **环境变量缺失或配置错误**: 如果系统中存在多个 Python 版本,则需要确保 `PATH` 环境变量指向的是被 `node-gyp` 支持的那个版本[^6]。 3. **Visual Studio 开发工具未正确安装**: `node-gyp` 还依赖于 Microsoft Visual Studio 提供的 C++ 编译器和构建工具链。缺少这些组件也会导致构建失败[^7]。 --- #### **解决方案** ##### 方法一:更新至受支持的 Python 版本 - 卸载现有不受支持的 Python 版本(如 Python 2.x)。 - 下载并安装最新的 Python 3.x(推荐从官网获取稳定版本:<https://www.python.org/>)。 - 将新安装的 Python 添加到系统的 `PATH` 环境变量中: ```plaintext PYTHON=C:\Path\To\Your\Python3x ``` - 验证是否成功设置: ```bash python --version ``` ##### 方法二:显式指定 Python 路径给 `npm` 即使已经安装了合适的 Python 版本,有时仍需手动告知 `npm` 使用哪个解释器。可通过以下方式实现: ```bash npm config set python "C:\Path\To\Your\Python3x" ``` ##### 方法三:安装必要的 Visual Studio 构建工具 为了满足 `node-gyp` 的需求,请按照以下步骤操作: 1. 访问微软官方网站 (<https://visualstudio.microsoft.com/>) 并下载免费的社区版 Visual Studio。 2. 在安装过程中勾选 “Desktop development with C++” 功能集。 3. 安装完毕后重启计算机以使更改生效。 或者,也可以单独安装轻量级的 Build Tools for Visual Studio: ```bash npm install --global windows-build-tools ``` 此命令会自动完成所需软件包的部署工作[^8]。 ##### 方法四:跳过原生模块编译流程 作为最后手段,在某些场景下可以考虑禁用本地扩展的重建过程来绕开这些问题。不过需要注意这样做可能会影响功能完整性: ```bash npm install --no-optional ``` --- #### **验证修复效果** 完成以上调整之后,重新尝试执行原始指令看是否恢复正常行为: ```bash npm install node-sass ``` --- ### 示例代码片段 下面展示了一个典型的 Vue CLI 项目中如何集成 SASS 支持的例子: ```javascript // vue.config.js module.exports = { css: { loaderOptions: { sass: { additionalData: '@import "@/assets/styles/global.scss";', }, }, }, }; ``` ---
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值