今天運行一個以前vue項目,啟動時報錯如下:
?ERROR ?Failed to compile with 1 error上午10:19:33
?error ?in ./src/App.vue?vue&type=style&index=0&lang=scss&
Syntax Error: Error: Missing binding D:\javacode\Springboot-MiMall-RSA\VueFront\node_modules\_node-sass@4.14.1@nod ? ? ? ? e-sass\vendor\win32-x64-83\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.xFound bindings for the following environments:
? - Windows 64-bit with Node.js 12.xThis usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
大致意思是:因為我把node 12升級成了14,?Node Sass庫的兼容性出問題了。
我當時沒多想,就把node_modules目錄刪除了,重新運行npm install,結果報錯:
No module named gyp
?網(wǎng)上查了一些資料說解決辦法如下:
1. 指定python2.7路徑:npm config set python python2.7
2.? ? 運行:npm install –no-optional
以上參考:https://spin.atomicobject.com/2019/03/27/node-gyp-windows/
?但是兩個方法都試過了,全部無效。
后來在一篇文章:node-sass,sass-loader,node-gyp,node報錯,版本對應問題
?找到解決辦法: 原來node版本跟node-sass有對應關系:
我之前的node-sass版本是4.12.0,把它修改成4.14.1 ,然后重新npm install就解決問題了
?
?此時我突然想起我啟動時第一次的報錯:
RSA\VueFront\node_modules\_node-sass@4.14.1@nod ? ? ? ? e-sass\vendor\win32-x64-83\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.xFound bindings for the following environments:
? - Windows 64-bit with Node.js 12.xThis usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
?上面的提示其實寫清楚了需要node-sass@4.14.1來匹配Node.js 14.x,建議修復命令:npm rebuild node-sass來修復。文章來源:http://www.zghlxwxcb.cn/news/detail-693870.html
我在想如果一開始我就運行:npm rebuild node-sass 這跟命令,也許問題就解決了文章來源地址http://www.zghlxwxcb.cn/news/detail-693870.html
到了這里,關于解決npm install報錯: No module named gyp的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!