错误场景

在搭建一个项目的前端部分时,正常流程是首先要运行npm install,之后npm run dev,但是这里在npm install时,发生了这样的报错
截图如下
在这里插入图片描述
然后下面还有这样的错误
生成失败。

“D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-sass\build\binding.sln”(默认目标) (1) ->
“D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-sass\build\binding.vcxproj.metaproj”(默认目标) (2) ->
“D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-sass\build\src\libsass.vcxproj”(默认目标) (3) ->
D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: 未找到导入的项目“D:\Microsoft.Cpp.Defau
lt.props
”。请确认 声明中的路径正确,且磁盘上存在该文件。

0 个警告
1 个错误

已用时间 00:00:00.74
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command “C:\Program Files\nodejs\node.exe” “D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-gyp\bin\node-gyp.js” “rebuild” “-
-verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
gyp ERR! cwd D:\IdeaWorkspace\mall-admin-web-master\node_modules\node-sass
gyp ERR! node -v v14.17.5
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN echarts-liquidfill@2.0.3 requires a peer of echarts@^4.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN v-charts@1.19.0 requires a peer of echarts@>3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,"arch
":“x64”})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.13.0 postinstall: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.13.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admister\AppData\Roaming\npm-cache_logs\2022-06-04T08_36_55_993Z-debug.log

分析

首先有这几种办法,根据在网上找和对日志文件的分析结合,大多是在node sass上下功夫,那么是否是没有安装这个模块呢
1、 安装sass
在idea或者vscode的终端里运行命令

npm install node-sass

在这里插入图片描述
安装成功后,再执行npm install,如下图,成功
在这里插入图片描述之后进行npm run dev
在这里插入图片描述
部署成功
2、 是否是没有管理员权限?
找到idea安装目录
在这里插入图片描述
赋予管理员权限
在这里插入图片描述

应用后就可以了

后续更新

后来在这个项目原先的说明里找到这个问题的解释,推荐的解决办法是这条命令

set SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass&& npm install node-sass

这个就是用淘宝镜像,会快一点

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐