React Native的Metro启动不了

问题描述

今天yarn start出现如下错误

metro-file-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: std::__1::system_error: open: /Users/couldhll/Desktop/Jesus: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: std::__1::system_error: open: /Users/couldhll/Desktop/Jesus: Operation not permitted
    at BunserBuf.<anonymous> (/Users/couldhll/Desktop/Jesus/node_modules/fb-watchman/index.js:99:23)
    at BunserBuf.emit (node:events:513:28)
    at BunserBuf.process (/Users/couldhll/Desktop/Jesus/node_modules/bser/index.js:292:10)
    at /Users/couldhll/Desktop/Jesus/node_modules/bser/index.js:247:12
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Emitted 'error' event on WatchmanWatcher instance at:
    at Client.<anonymous> (/Users/couldhll/Desktop/Jesus/node_modules/metro-file-map/src/watchers/WatchmanWatcher.js:107:12)
    at Client.emit (node:events:513:28)
    at BunserBuf.<anonymous> (/Users/couldhll/Desktop/Jesus/node_modules/fb-watchman/index.js:111:12)
    at BunserBuf.emit (node:events:513:28)
    at /Users/couldhll/Desktop/Jesus/node_modules/bser/index.js:249:12
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  watchmanResponse: {
    error: 'std::__1::system_error: open: /Users/couldhll/Desktop/Jesus: Operation not permitted',
    version: '2022.11.14.00'
  }
}

Node.js v18.12.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

问题解决

在终端使用如下命令:

步骤一

watchman watch-del-all

步骤二

watchman shutdown-server

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注