[英]Cannot add node-sass using npm in my react project I am development on my mac
[英]node-sass Issue on my angular project npm install (Mac OS)
我嘗試為我的 angular 項目安裝 node_modules 我遇到 node-sass 的問題我使用 mac os,node js 版本 -> v16.13.2,項目中的 node-sass 版本 ->^4.14.1 在這個image1和image2是 ZEFE90A8E604A7C840E8Z8D03A67F6B7D .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
您可能希望運行npm upgrade
以讓 npm 檢查您的依賴項的過時版本。
因為對於節點 16,您需要 6.0+ 版本中的 node-sass
只需從您的 package.json 中刪除 node-sass ... 即可解決我的問題
嘗試這樣做,它的工作原理。 您需要使用以下塊之一將其從package.json
中刪除。
如果您使用的是npm
並且node-sass
在您的dependencies
項中:
npm uninstall node-sass --save
npm install node-sass --save
如果您使用的是npm
並且node-sass
在您的devDependencies
中:
npm uninstall node-sass --save-dev
npm install node-sass --save-dev
如果您使用的是yarn
並且node-sass
在您的dependencies
項中:
yarn remove node-sass --save
yarn add node-sass --save
如果您使用的是yarn
並且node-sass
在您的devDependencies
中:
yarn remove node-sass --save-dev
yarn add node-sass --save-dev
我找到了解決這個問題的方法。 只需降級節點版本即可
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.