Problem Description:
When moving a folder item or a copied item, run the error: cannot find module ‘xxx’
Solution:
Delete node_ In the modules folder, delete the package-lock.json file, then NPM install, and then run the project
The following is the complete error message
PS D:\test> npm run dev
> [email protected] dev D:\test
> vite
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'esbuild'
Require stack:
- D:\test\node_modules\[email protected]@vite\dist\node\chunks\dep-85dbaaa7.js
- D:\test\node_modules\[email protected]@vite\dist\node\cli.js
- D:\test\node_modules\[email protected]@vite\bin\vite.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (D:\test\node_modules\[email protected]@vite\dist\node\chunks\dep-85dbaaa7.js:13:15)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\test\\node_modules\\[email protected]@vite\\dist\\node\\chunks\\dep-85dbaaa7.js',
'D:\\test\\node_modules\\[email protected]@vite\\dist\\node\\cli.js',
'D:\\test\\node_modules\\[email protected]@vite\\bin\\vite.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\xxx\AppData\Roaming\npm-cache\_logs\2021-11-01T02_40_03_715Z-debug.log