vue基础-解决Cannot find package ‘vite‘ imported from xxxx问题


文章目录

  • 前言
  • 一、错误信息:
  • 二、解决方法:
  • 总结


前言

最近介绍接手新的vue项目,想运行起来发现下面一个错误。


一、错误信息:

failed to load config from /Users/xxxx/backend/vite.config.ts
error when starting dev server:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite' imported from /Users/xxxxx/vite.config.ts.timestamp-1692258569249-f359db1b06b5f.mjs
    at new NodeError (node:internal/errors:399:5)
    at packageResolve (node:internal/modules/esm/resolve:889:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:20)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap. (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36)
 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.

二、解决方法:

1、运行sudo pnpm install vite --save-dev

总结

这就是解决Cannot find package ‘vite’ imported from xxxx问题的方法,希望能帮助到你!

你可能感兴趣的:(vue,vue.js,javascript,前端)