背景
最近用create-react-app構(gòu)建react項目過程中熬甫,使用官方推薦的方法處理scss文件的編譯問題蜀撑,即node-sass-chokidar
,編輯器使用VSCode,在修改scss文件并保存的過程中蟹地,出現(xiàn)編譯失敗的問題授翻,報錯內(nèi)容為File to read not found or unreadable
或悲,具體如下
{
"status": 3,
"message": "File to read not found or unreadable: E:/learn/react-app1/src/index.scss",
"formatted": "Internal Error: File to read not found or unreadable: E:/learn/react-app1/src/index.scss\n"
}
解決
直接上github的Issue找,這種問題一般不會是個人問題堪唐,果不其然巡语,發(fā)現(xiàn)了相關(guān)的Issue,一步一步跟進(jìn)最終找到了解決方法淮菠,在node-sass項目的Issue下男公,解決要點:
- 由
marcosbozzani
大神做了修復(fù),修復(fù)分支bug-vscode-watch
- 此時node-sass最新版本為
4.9
合陵,版本中未處理此問題 - 需要手動修復(fù)枢赔,替換
node_modules/node-sass/lib/render.js
為render.js
此問題并不是node-sass的問題澄阳,主要是vscode鎖定了文件而造成了文件不可讀,marcosbozzani
大神是這么說的The problem seems to be VSCode is still holding the file while node-sass try to access it.
在此記錄一下問題及解決方法踏拜,分享給有需要的朋友