現象
在 windows 7 環境下,Vue 2.4+ 版本 npm i 全部安裝完成后,運行 npm run dev 或者 npm run build 命令會出現錯誤:
Error: Could not load C:\vue\src\core/config (imported by C:\vue\src\platforms\web\entry-runtime-with-compiler.js): ENOENT: no such file
or directory, open 'C:\vue\src\core\config'
原因
rollup-plugin-alias 插件沒有把 windows 的路徑轉換掉:'/' 沒有轉為 '\'
解決辦法
實際上該插件已經有人提交 PR 了,但是沒有合並的緣故,因此仍有這個 bug。
可以更改 node_modules/rollup-plugin-alias/dist/rollup-plugin-alias.js
第87行:
var entry = options[toReplace];
改為 var entry = normalizeId(options[toReplace]);
即可。