node:internal/modules/cjs/loader:936 throw err; ^ Error: Cannot find module ‘./scope‘

穆毅然
2023-12-01

报错信心如下:
node:internal/modules/cjs/loader:936
throw err;
^

Error: Cannot find module ‘./scope’
Require stack:

  • D:…\node_modules\ajv-formats\node_modules\ajv\dist\compile\codegen\index.js
  • D:…\node_modules\ajv-formats\dist\limit.js
  • D:…\node_modules\ajv-formats\dist\index.js
  • D:…\node_modules\eslint-webpack-plugin\node_modules\schema-utils\dist\validate.js
  • D:…\node_modules\eslint-webpack-plugin\node_modules\schema-utils\dist\index.js
  • D:…\node_modules\eslint-webpack-plugin\dist\options.js
  • D:…\node_modules\eslint-webpack-plugin\dist\index.js
  • D:…\node_modules@vue\cli-plugin-eslint\index.js
  • D:…\node_modules@vue\cli-service\lib\Service.js
  • D:…\node_modules@vue\cli-service\bin\vue-cli-service.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (D:…\node_modules\ajv-formats\node_modules\ajv\dist\compile\codegen\index.js:5:17)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions…js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
    code: ‘MODULE_NOT_FOUND’,
    requireStack: [
    ‘D:\…\node_modules\ajv-formats\node_modules\ajv\dist\compile\codegen\index.js’,
    ‘D:\…\node_modules\ajv-formats\dist\limit.js’,
    ‘D:\…\node_modules\ajv-formats\dist\index.js’,
    ‘D:\…\node_modules\eslint-webpack-plugin\node_modules\schema-utils\dist\validate.js’,
    ‘D:…\node_modules\eslint-webpack-plugin\node_modules\schema-utils\dist\index.js’,
    ‘D:\…\node_modules\eslint-webpack-plugin\dist\options.js’,
    ‘D:\…\node_modules\eslint-webpack-plugin\dist\index.js’,
    ‘D:\…\node_modules\@vue\cli-plugin-eslint\index.js’,
    ‘D:\…\node_modules\@vue\cli-service\lib\Service.js’,
    ‘D:\…\node_modules\@vue\cli-service\bin\vue-cli-service.js’
    ]
    }

发生时机:刚刚npm install之后使用npm run serve启动项目报了这个错误。

原因(猜测):应该是npm install的时候因为网络或者其他原因导致某些npm包遗漏或者没下载下来。

解决:
删除node_modules文件夹和生成的package-lock.json,然后重新npm install再启动项目。

 类似资料: