启动反应应用程序时出错
Posted
技术标签:
【中文标题】启动反应应用程序时出错【英文标题】:error when starting react app 【发布时间】:2019-01-09 09:46:34 【问题描述】:我使用 React v15.6.1 和 Yarn,我尝试从终端启动 react 应用程序,但是当我执行命令“yarn start”时抛出错误并且不运行应用程序
日志:纱线开始
Starting the development server...
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /home/navastud/atom-workspace/intervijs/public ENOSPC
at _errnoException (util.js:1022:11)
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
at createFsWatchInstance (/home/navastud/atom-workspace/intervijs/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/navastud/atom-workspace/intervijs/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/navastud/atom-workspace/intervijs/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleDir (/home/navastud/atom-workspace/intervijs/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:407:19)
at FSWatcher.<anonymous> (/home/navastud/atom-workspace/intervijs/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:455:19)
at FSWatcher.<anonymous> (/home/navastud/atom-workspace/intervijs/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:460:16)
at FSReqWrap.oncomplete (fs.js:153:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
所以我尝试执行命令“npm install”,但没有显示其他错误。
日志:npm install
multicomp@0.1.0 /home/navastud/atom-workspace/intervijs
├─┬ eslint@5.2.0
│ ├── chalk@2.4.1
│ ├─┬ inquirer@5.2.0
│ │ └─┬ string-width@2.1.1
│ │ └─┬ strip-ansi@4.0.0
│ │ └── ansi-regex@3.0.0
│ ├─┬ js-yaml@3.12.0
│ │ └── esprima@4.0.1
│ ├─┬ strip-ansi@4.0.0
│ │ └── ansi-regex@3.0.0
│ └─┬ table@4.0.3
│ ├── UNMET PEER DEPENDENCY ajv@6.5.2
│ └── chalk@2.4.1
├─┬ eslint-config-equimper@2.2.2
│ ├─┬ babel-eslint@8.2.6
│ │ └─┬ @babel/code-frame@7.0.0-beta.44
│ │ └─┬ @babel/highlight@7.0.0-beta.44
│ │ └── chalk@2.4.1
│ ├─┬ UNMET PEER DEPENDENCY eslint@4.19.1
│ │ ├── chalk@2.4.1
│ │ ├─┬ espree@3.5.4
│ │ │ └─┬ acorn-jsx@3.0.1
│ │ │ └── acorn@3.3.0
│ │ ├── ignore@3.3.10
│ │ ├─┬ inquirer@3.3.0
│ │ │ ├── chalk@2.4.1
│ │ │ └─┬ strip-ansi@4.0.0
│ │ │ └── ansi-regex@3.0.0
│ │ ├─┬ js-yaml@3.12.0
│ │ │ └── esprima@4.0.1
│ │ └─┬ strip-ansi@4.0.0
│ │ └── ansi-regex@3.0.0
│ └─┬ eslint-plugin-class-property@1.1.0
│ └─┬ eslint@3.19.0
│ ├─┬ espree@3.5.4
│ │ └─┬ acorn-jsx@3.0.1
│ │ └── acorn@3.3.0
│ ├── ignore@3.3.10
│ └─┬ table@3.8.3
│ └─┬ string-width@2.1.1
│ └─┬ strip-ansi@4.0.0
│ └── ansi-regex@3.0.0
├── UNMET PEER DEPENDENCY react@15.6.2
├── UNMET PEER DEPENDENCY react-dom@15.6.2
└─┬ react-scripts@1.1.4
├─┬ autoprefixer@7.1.6
│ └─┬ postcss@6.0.23
│ └── chalk@2.4.1
├─┬ UNMET PEER DEPENDENCY eslint@4.10.0
│ ├── chalk@2.4.1
│ ├── eslint-scope@3.7.3
│ ├─┬ espree@3.5.4
│ │ └─┬ acorn-jsx@3.0.1
│ │ └── acorn@3.3.0
│ ├── ignore@3.3.10
│ ├─┬ js-yaml@3.12.0
│ │ └── esprima@4.0.1
│ └─┬ strip-ansi@4.0.0
│ └── ansi-regex@3.0.0
└─┬ sw-precache-webpack-plugin@0.11.4
└─┬ sw-precache@5.2.1
└─┬ update-notifier@2.5.0
├─┬ boxen@1.3.0
│ └── chalk@2.4.1
└── chalk@2.4.1
npm WARN optional Skipping failed optional dependency /react-scripts /fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4
npm WARN optional Skipping failed optional dependency /webpack-dev-server/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none was installed.
npm WARN eslint-config-react-app@2.1.0 requires a peer of eslint@^4.1.1 but none was installed.
npm WARN eslint-loader@1.9.0 requires a peer of eslint@>=1.6.0 <5.0.0 but none was installed.
npm WARN eslint-plugin-import@2.8.0 requires a peer of eslint@2.x - 4.x but none was installed.
npm WARN eslint-plugin-jsx-a11y@5.1.1 requires a peer of eslint@^2.10.2 || ^3 || ^4 but none was installed.
npm WARN eslint-plugin-react@7.4.0 requires a peer of eslint@^3.0.0 || ^4.0.0 but none was installed.
npm WARN react-d3-speedometer@0.3.2 requires a peer of react@^0.14.7 || ^16.0.0 but none was installed.
npm WARN react-svg-gauge@1.0.8 requires a peer of react@^16.2.0 but none was installed.
npm WARN react-svg-gauge@1.0.8 requires a peer of react-dom@^16.2.0 but none was installed.
为什么会发生这种情况以及如何解决?
【问题讨论】:
您是否尝试过删除所有依赖项并从头开始安装所有内容?rm -rf ./node_modules && npm install
谢谢,工作正常,但是为什么会这样呢?
太棒了!发生这种情况的原因有很多,很难说在这种特殊情况下可能出了什么问题。
如果重新安装 node_modules 有效,很可能是因为库损坏了。
如何知道是否存在损坏的库并进行修复??
【参考方案1】:
可以使用以下命令:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
【讨论】:
【参考方案2】:很难确切说明为什么会出现此错误,但如果您删除 node_modules
目录并重新安装每个依赖项,它应该可以按预期工作。
rm -rf ./node_modules && npm install
【讨论】:
以上是关于启动反应应用程序时出错的主要内容,如果未能解决你的问题,请参考以下文章