我有一些位于__tests__
目录中的帮助程序模块,这些模块也已导出。这是我的目录结构。有两个软件包A和B。我正在从A的__tests__
目录中导出fileA并尝试在B内部使用它。
A
├── dist
├── node_modules
├── src
│ ├── __tests__
│ │ ├── __helpers__
│ │ │ ├── fileA.ts
│ │ └── integration.test.ts
B
├── dist
├── node_modules
├── src
│ ├── __tests__
│ │ └── integration.test.ts
但是它无法解析模块,并引发以下错误:
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `./__tests__/__helpers__/fileA` from
`/Users/xyz/project/packages/A/dist/index.js`:
The module `./__tests__/__helpers__/fileA` could not be found from `/Users/xyz/project/packages/A/dist/index.js`. Indeed, none of these files exist:
* `/Users/xyz/project/packages/A/dist/__tests__/__helpers__/fileA(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
* `/Users/xyz/project/packages/A/dist/__tests__/__helpers__/fileA/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
但是文件确实存在。
React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 99.84 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 11.1.0 - ~/.nvm/versions/node/v11.1.0/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v11.1.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 22.0.1, 23.0.1, 25.0.0, 25.0.2, 26.0.0, 26.0.2
API Levels: 19, 21, 23, 24, 25, 26
IDEs:
Android Studio: 3.1 AI-173.4720617
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.2 => 0.57.2
npmGlobalPackages:
react-native-cli: 2.0.1