在新机器上配置完node.js、vue-cli,配置了node_modules后,命令行运行vue ui
后,出现了如下报错:
C:\Users\LEN>vue ui
Starting GUI...
Ready on http://localhost:8000
node:events:496
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, scandir 'D:\kob_demo\web\node_modules\@vue\cli-service\locales'
at Object.readdirSync (node:fs:1515:26)
at exports.readdir (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@mrmlnc\readdir-enhanced\lib\sync\fs.js:18:20)
at Object.safeCall [as safe] (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@mrmlnc\readdir-enhanced\lib\call.js:24:8)
at DirectoryReader.readNextDirectory (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@mrmlnc\readdir-enhanced\lib\directory-reader.js:78:10)
at DirectoryReader.stream._read (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@mrmlnc\readdir-enhanced\lib\directory-reader.js:57:18)
at Readable.read (node:internal/streams/readable:737:12)
at readdirSync (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@mrmlnc\readdir-enhanced\lib\sync\index.js:27:21)
at Function.readdirSyncStat (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@mrmlnc\readdir-enhanced\lib\index.js:34:10)
at ReaderSync.dynamicApi (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\fast-glob\out\providers\reader-sync.js:64:24)
at ReaderSync.api (C:\Users\LEN\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\fast-glob\out\providers\reader-sync.js:56:25)
Emitted 'error' event on Readable instance at:
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'scandir',
path: 'D:\\kob_demo\\web\\node_modules\\@vue\\cli-service\\locales'
}
Node.js v20.11.0
尝试在环境变量里添加C:\Windows\System32
,但是没有效果,根据报错信息,原因是缺少locales文件夹path: 'D:\\kob_demo\\web\\node_modules\\@vue\\cli-service\\locales'
,在该路径下创建文件夹,将其命名为locales
即可。
之后再次执行vue ui
命令,还是会报错,不出意外是相同类型的报错,使用相同方法解决即可,这里给出作者总共解决的路径:
path: 'D:\\kob_demo\\web\\node_modules\\@vue\\cli-plugin-babel\\locales'
path: 'D:\\kob_demo\\web\\node_modules\\@vue\\cli-plugin-eslint\\locales'
path: 'D:\\kob_demo\\web\\node_modules\\@vue\\cli-plugin-router\\locales'
path: 'D:\\kob_demo\\web\\node_modules\\@vue\\cli-plugin-vuex\\locales'