npm create vite@latest Error: cannot find package 'vite' imported from .../vite.config.ts
Error content
> xxxx dev:mock xxx/xxxx/xxxxx
> cross-env VITE_SERVICE_ENV=dev VITE_IS_MOCK=Y vite
failed to load config from xxx/xxxx/xxxxx/vite.config.ts
error when starting dev server:
Error: spawn Unknown system error -8
at ChildProcess.spawn (internal/child_process.js:408:11)
at spawn (child_process.js:677:9)
at Object.spawnWithSignal [as spawn] (child_process.js:911:17)
at ensureServiceIsRunning (xxx/xxxx/xxxxx/node_modules/esbuild/lib/main.js:1491:29)
at build (xxx/xxxx/xxxxx/node_modules/esbuild/lib/main.js:1404:26)
at bundleConfigFile (file://xxx/xxxx/xxxxx/node_modules/vite/dist/node/chunks/dep-ca21228b.js:62245:26)
at loadConfigFromFile (file://xxx/xxxx/xxxxx/node_modules/vite/dist/node/chunks/dep-ca21228b.js:62221:31)
at resolveConfig (file://xxx/xxxx/xxxxx/node_modules/vite/dist/node/chunks/dep-ca21228b.js:61843:34)
at createServer (file://xxx/xxxx/xxxxx/node_modules/vite/dist/node/chunks/dep-ca21228b.js:61153:26)
at CAC.<anonymous> (file://xxx/xxxx/xxxxx/node_modules/vite/dist/node/cli.js:734:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxxxx dev:mock: `cross-env VITE_SERVICE_ENV=dev VITE_IS_MOCK=Y vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xxxx dev:mock 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! xxxx/.npm/_logs/xxx-debug.log
Update, solution:
npm install --include=dev
While not a solution to the root cause, it does work. *
The actual root cause was:
npm install did not install devDependencies in the autogenerated package.json by default...