首页 > 解决方案 > 为什么 npm start 给我“错误:找不到模块'./keywords'”?

问题描述

尝试npm start与 Create React App 一起使用来启动我的反应应用程序,但收到此错误:

node:internal/modules/cjs/loader:943
  throw err;
  ^

Error: Cannot find module './keywords'
Require stack:
- D:\social-ribbon\node_modules\ajv-keywords\index.js
- D:\social-ribbon\node_modules\webpack\node_modules\schema-utils\src\validateOptions.js
- D:\social-ribbon\node_modules\webpack\node_modules\schema-utils\src\index.js
- D:\social-ribbon\node_modules\webpack\lib\SourceMapDevToolPlugin.js
- D:\social-ribbon\node_modules\webpack\lib\WebpackOptionsApply.js
- D:\social-ribbon\node_modules\webpack\lib\webpack.js
- D:\social-ribbon\node_modules\react-scripts\scripts\start.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at Function.Module._load (node:internal/modules/cjs/loader:773:27)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (D:\social-ribbon\node_modules\ajv-keywords\index.js:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Module.require (node:internal/modules/cjs/loader:1012:19) {
  requireStack: [
    'D:\\social-ribbon\\node_modules\\ajv-keywords\\index.js',
    'D:\\social-ribbon\\node_modules\\webpack\\node_modules\\schema-utils\\src\\validateOptions.js',
    'D:\\social-ribbon\\node_modules\\webpack\\node_modules\\schema-utils\\src\\index.js',
    'D:\\social-ribbon\\node_modules\\webpack\\lib\\SourceMapDevToolPlugin.js',
    'D:\\social-ribbon\\node_modules\\webpack\\lib\\WebpackOptionsApply.js',
    'D:\\social-ribbon\\node_modules\\webpack\\lib\\webpack.js',
    'D:\\social-ribbon\\node_modules\\react-scripts\\scripts\\start.js'
  ]
}

有人建议搜索名为“keywords”的文件,但该词仅作为ajv-keywordsor的一部分出现在文件中css-color-keywords。其他人建议重新安装整个node-modules文件夹,但这听起来有点激烈。我现在请你帮忙。谢谢你的帮助。

标签: node.jsnpmcreate-react-appnpm-start

解决方案


我也面临同样的问题。我所做的是删除节点模块文件夹并重新安装它。我也会分享命令

 rm -R node_modules
 npm cache --force clean
 npm cache --force clear
 npm install
 npm start

希望这有效。它对我有用,但在我的情况下,有一个 avj-keywords 文件夹。


推荐阅读