vite buildfailed to load config from /pengBlog-master Cannot find package ‘@vitejs/plugin-react‘ imp

问:

pengIndex % vite build
failed to load config from /pengBlog-master/pengIndex/vite.config.ts
error during build:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@vitejs/plugin-react' imported from pengBlog-master/pengIndex/vite.config.ts.timestamp-1696164772193.mjs
    at new NodeError (node:internal/errors:387:5)
    at packageResolve (node:internal/modules/esm/resolve:852:9)
    at moduleResolve (node:internal/modules/esm/resolve:901:20)
    at defaultResolve (node:internal/modules/esm/resolve:1115:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap. (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)

回答:

这个错误提示显示在运行vite build命令时出现了问题。错误信息指出无法找到 @vitejs/plugin-react 软件包。

为了解决该问题,请确保该软件包安装在项目的依赖项中。你可以使用以下命令尝试安装该依赖项:

 
   

npm install @vitejs/plugin-react --save-dev

安装完成后,请再次运行 vite build 命令并查看是否仍有错误发生

你可能感兴趣的:(前端,javascript,开发语言)