React Native-无法从'index.js'解析模块@ babel / runtime / helpers / interopRequireDefault

时间:2019-11-22 07:38:51

标签: node.js react-native npm react-native-android npm-start

Unable to resolve module `@babel/runtime/helpers/interopRequireDefault`中所述,我遇到了相同的错误,该问题的解决方案无法解决我的问题。

React Native - Unable to resolve module `@babel/runtime/helpers/interopRequireDefault`都无法解决我的问题。

我正在使用

R_peak = False   
j = 0
k = 0
idx_rr = []
sig = []

for i in range (len(sig_txt)):
    if (sig_txt[i] == 32767):
        idx_rr = i+1
        idx_rr[j] = np.array(sig_txt[i+1])
        sig = i+1
        sig[k] = np.array(sig_txt[i+1])
        k = k + 1
        j = j + 1
        print(idx_rr)
        R_peak = True
    else:
        if (R_peak == False):
            sig = i
            sig[k] = np.array(sig_txt[i])
            k = k + 1

        else:
            R_peak = False

plt.figure(figsize=(20,8))
plt.plot(sig)
plt.scatter([idx_rr], [sig[idx_rr]], c='g')  
plt.show() 

TypeError Traceback (most recent   call last)
<ipython-input-1474-dcea2717b9f2> in <module>
----> 1 get_intervals('/home/yasaswini/hp2-notebooks/ecg_data   
/Recorded_Data_Patch_Simulator/TXT_Files   
/ECG_data_128Hz_Simulator_Patch_Normal_data.txt',128)

<ipython-input-1471-5a6b384defd1> in get_intervals(fname,sampling_rate)
22             if (R_peak == False):
23                 sig = i
---> 24                 sig[k] = np.array(sig_txt[i])
25                 k = k + 1
26 

TypeError: 'int' object does not support item assignment

错误提示:

 OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    Memory: 2.03 GB / 7.92 GB
  Binaries:
    Node: 12.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.19.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.12.1 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5977832
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.4 => 0.61.4

该模块存在,我已经尝试了上述步骤,但仍然无法正常工作。 该应用实际上通过消息error: bundling failed: Error: Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `index.js`: @babel/runtime/helpers/interopRequireDefault could not be found within the project. If you are sure the module exists, try these steps: 1. Clear watchman watches: watchman watch-del-all 2. Delete node_modules: rm -rf node_modules and run yarn install 3. Reset Metro's cache: yarn start --reset-cache 4. Remove the cache: rm -rf /tmp/metro-* at ModuleResolver.resolveDependency (C:\ReactProjects\testy\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:186:15) at ResolutionRequest.resolveDependency (C:\ReactProjects\testy\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18) at DependencyGraph.resolveDependency (C:\ReactProjects\testy\node_modules\metro\src\node-haste\DependencyGraph.js:282:16) at Object.resolve (C:\ReactProjects\testy\node_modules\metro\src\lib\transformHelpers.js:267:42) at C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:426:31 at Array.map (<anonymous>) at resolveDependencies (C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:423:18) at C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33 at Generator.next (<anonymous>) at asyncGeneratorStep (C:\ReactProjects\testy\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24) BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed. 成功构建 当应用程序运行时,出现与上述相同的错误。 任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

my case中,问题不是由RN引起的,而是由watchman引起的。

有两种方法可以解决此问题,直到修复潜在的错误为止:

首先要卸载watchman

或手动编辑文件node_modules/jest-haste-map/build/index.js进行更改:

    const crawl =
      canUseWatchman && this._options.useWatchman
        ? _watchman.default
        : _node.default;

收件人:

    const crawl =
      canUseWatchman && this._options.useWatchman
        ? _node.default
        : _node.default;

后者当然不会在软件包升级中持续存在。