【问题标题】:node-sass Issue on my angular project npm install (Mac OS)我的角度项目 npm install (Mac OS) 上的 node-sass 问题
【发布时间】:2023-04-04 18:49:01
【问题描述】:

我尝试为我的 Angular 项目安装 node_modules,但我遇到了 node-sass 的问题 我在项目中使用mac os,node js版本-> v16.13.2,node-sass版本->^4.14.1 在这个 image1 和 image2 是 package.json 我得到的错误是:

npm ERR! 1 warning and 1 error generated.
npm ERR! make: *** [Release/obj.target/binding/src/binding.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (../node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" ".../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd .../node_modules/node-sass
npm ERR! gyp ERR! node -v v16.13.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!     .../.npm/_logs/2022-01-25T10_04_49_137Z-debug-0.log

我绑定了这个命令 npm install -g node-sass, npm uninstall -g node-sass 同样,我尝试安装最新版本的 node-sass

【问题讨论】:

    标签: node.js angular npm sass


    【解决方案1】:

    您可能希望运行 npm upgrade 让 npm 检查您的依赖项的过时版本。

    因为对于节点 16,您需要 6.0+ 版本的 node-sass

    【讨论】:

    • 如果我将 node-sass 更新到 6.0+ 版本,我会收到此错误“错误:Node Sass 版本 6.0.1 与 ^4.0.0 不兼容。”
    • 先卸载 node-sass,然后重新安装可能会有所帮助。所以首先npm uninstall node-sass 然后npm i node-sass
    • 我做了好几次都没有:(
    • 您在哪里运行您的网络项目?既然你是在 macOS 上编写的,这是否意味着你不使用像 Docker、Homestead/Valet 或 MAMP 这样的虚拟主机?
    【解决方案2】:

    只需从你的 package.json 中删除 node-sass ...这为我解决了问题

    【讨论】:

      【解决方案3】:

      我找到了解决这个问题的方法。只需降级节点版本就可以了

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。
      猜你喜欢
      • 2022-11-01
      • 2018-08-05
      • 2023-03-18
      • 2021-05-02
      • 2020-02-06
      • 2020-10-22
      • 1970-01-01
      • 2014-08-15
      • 1970-01-01
      相关资源
      最近更新 更多