ReactNative:尝试调试无法找到模块

时间:2020-08-24 15:06:20

标签: reactjs react-native

我正在尝试调试我的应用程序。在过去,一切都很好。然后,我格式化了计算机,下载了从git保存的项目。

在这一点上,每次我尝试在终端中运行npm start或使用Visual Studio代码的react native工具调试应用程序或在任何情况下更新连接到我的设备的应用程序时,此错误:

Error: Cannot find module '/Users/..../node_modules/@react-native-community/cli/build/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:338:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:719:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1072:27)
    at Function.Module._load (internal/modules/cjs/loader.js:928:27)
    at Module.require (internal/modules/cjs/loader.js:1145:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/Users/.../node_modules/react-native/cli.js:12:11)
    at Module._compile (internal/modules/cjs/loader.js:1256:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
    at Module.load (internal/modules/cjs/loader.js:1105:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/..../node_modules/@react-native-community/cli/package.json',
  requestPath: '@react-native-community/cli'

我不知道该怎么办。

我记得在更改代码之前,我只需要运行npm start重新加载项目并查看设备中的更改。现在,我绝对无法让代码和设备进行交互。

我该怎么办?

1 个答案:

答案 0 :(得分:0)

您尝试重新安装React LI:

npm install –g react-native-cli

并安装依赖项:

npm install