启动 create-react-app 项目期间未处理的错误

Unhandled error during starting create-react-app project

我通过 create-react-app 创建了一个新项目。项目成功创建后,我试图通过点击命令 yarn start 来启动项目,但它抛出了一个未处理的错误。

谁有解决这个问题的好方法。

Starting the development server...

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: watch /home/sagar/workspace/code-splitting/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/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:232:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:414:19)
    at FSWatcher.<anonymous> (/home/sagar/w    Starting the development server...

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: watch /home/sagar/workspace/code-splitting/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/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:232:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:414:19)
    at FSWatcher.<anonymous> (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:462:19)
    at FSWatcher.<anonymous> (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:467: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.orkspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:462:19)
    at FSWatcher.<anonymous> (/home/sagar/workspace/code-splitting/node_modules/chokidar/lib/nodefs-handler.js:467: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.

要解决此问题,您可以按照以下步骤操作。

首先,重新安装node_modules

rm -rf node_modules/ && npm i

然后,启动项目:

npm start 

yarn start

重新安装依赖项是解决方案。

删除node_modules目录

然后:

yarn install

使用 npm install 重新安装节点模块 并做

npx create-react-app my-app cd my-app npm start

https://github.com/facebook/create-react-app/issues/3486#issuecomment-346485194

上找到解决方案
sudo yarn start

信用:@robininfo-edsx “当前错误是 ENOSPC(不够space) 它与权限没有直接关系,但通常与磁盘使用情况有关,当您达到可以观看的文件限制时。 作为 root 的 watch 限制可能比正常使用大,这就是为什么 sudo 解决了这个问题但是 运行 作为 root 的应用程序是不可取的。 尝试增加可观看文件的限制