使用npm run dev启动vite项目报错:
> vite
internal/modules/cjs/loader.js:1174
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: E:\works\large-file-uploader\node_modules\vite\bin\vite.js
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1174:13)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'ERR_REQUIRE_ESM'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! large-file-uploader@0.0.0 dev: `vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the large-file-uploader@0.0.0 dev 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\Administrator\AppData\Roaming\npm-cache\_logs\2023-08-15T09_13_59_734Z-debug.log
原因:nodejs版本太低文章来源:https://www.toymoban.com/news/detail-740557.html
vue3+vite项目需要使用nodejs16及以上版本才能正常运行,修改nodejs版本后成功启动文章来源地址https://www.toymoban.com/news/detail-740557.html
到了这里,关于Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: E:\works\large-file-uploader\node_module的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!