我正在尝试使用express,但是每当我在代码中需要它时,它就会中断我的项目。这就是它的坏处...
var express = require('express');
当我对此发表评论时,我可以构建我的项目,但是当我将其留在里面时,我将无法编译。
这是错误消息。
error: bundling failed: Error: Unable to resolve module `events` from `C:\Users\...\Desktop\React\payme\node_modules\express\node_modules\depd\index.js`: Module `events` does not exist in the Haste module map
这可能与https://github.com/facebook/react-native/issues/4968有关 要解决此问题,请尝试以下操作:
watchman watch-del-all
。node_modules
文件夹:rm -rf node_modules && npm install
。rm -rf /tmp/metro-bundler-cache-*
或npm start -- --reset-cache
。rm -rf /tmp/haste-map-react-native-packager-*
。
在ModuleResolver.resolveDependency(C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ node-haste \ DependencyGraph \ ModuleResolution.js:183:15)
在ResolutionRequest.resolveDependency(C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ node-haste \ DependencyGraph \ ResolutionRequest.js:52:18)
在DependencyGraph.resolveDependency(C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ node-haste \ DependencyGraph.js:283:16)
在Object.resolve(C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ lib \ transformHelpers.js:261:42)
在C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:399:31
在Array.map()
在resolveDependencies(C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:396:18)
在C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:269:33
在Generator.next()
在asyncGeneratorStep(C:\ Users ... \ Desktop \ React \ payme \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:87:24)