node-sass 安裝失敗解決方法

部署項(xiàng)目時(shí),npm install 出現(xiàn)下圖錯誤

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node":
………………
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python D:\Asoftware\python\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: D:\Asoftware\python\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[
:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:390:12)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "D:\\Asoftware\\Nodejs\\node.exe" "D:\\autotest\\ebs_atm\\ebs-atm-web\\node_modules\\node-gyp\\bin\\nod
e-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\autotest\ebs_atm\ebs-atm-web\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 optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any
"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.12.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\jingzhou\AppData\Roaming\npm-cache\_logs\2021-08-25T06_41_01_253Z-debug.log

Process finished with exit code 1
Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node":

報(bào)上圖的錯誤的原因:node-sass模塊無法成功下載,并非python的版本問題
在node_modules文件夾,打開cmd窗口,通過淘寶鏡像下載node-sass模塊
命令如下:

npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
下載成功的圖片.png

ps:由于我的項(xiàng)目的package.json中,版本過低,在下載的時(shí)候,自動升級成"^4.14.1"版本


package.json文件顯示.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容