gpt4 book ai didi

reactjs - react-native : Unable to resolve module `tty` from '' . ../node_modules/window-size/index.js": 模块映射中不存在模块

转载 作者:行者123 更新时间:2023-12-03 13:25:21 24 4
gpt4 key购买 nike

Error

    loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `tty` from `/MyWorks/rnTestTrials/myCurrencySample/node_modules/window-size/index.js`: Module does not exist in the module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
at ModuleResolver.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:1476)
at ResolutionRequest.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:92:16)
at DependencyGraph.resolveDependency (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/node-haste/DependencyGraph.js:271:4465)
at dependencies.map.relativePath (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:379:19)
at Array.map (<anonymous>)
at resolveDependencies (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:378:16)
at /MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:203:33
at Generator.next (<anonymous>)
at step (/MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:296:307)
at /MyWorks/rnTestTrials/myCurrencySample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:296:467
BUNDLE [ios, dev] ./index.js ▓▓▓▓▓▓▓▓▓░░░░░░░ 60.2% (291/375), failed.

--

我厌倦了错误中给定的解决方案,并删除并重新启动 npm 并从 "./ios" 中删除构建并再次运行 'react-native run-ios'

这个应用程序运行完美,但突然显示此错误并停止工作,

enter image description here

厌倦了网络上所有与 npm_module 相关的解决方案,

versions

react-native-cli: 2.0.1
react-native: 0.54.0

package.json

{
"name": "myCurrencySample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"color": "2.0.0",
"moment": "2.18.1",
"react": "^16.3.0-alpha.1",
"react-native": "^0.54.0",
"react-native-extended-stylesheet": "^0.8.1"
},
"devDependencies": {
"babel-jest": "22.4.1",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.2",
"react-test-renderer": "^16.3.0-alpha.1"
},
"jest": {
"preset": "react-native"
}
}

请帮忙,

最佳答案

我得到了与你完全相同的错误,我意识到在导入不同的模块时,我不小心导入了这个“import { width } from 'window-size';”,这通常发生在 IntelliSense 打开时,对于某些人来说像 Visual Studio Code 这样的 IED 会导入一行您不打算放入的代码。因此,要回答您的问题,请检查您的文件,可能是您正在处理的最后一个文件,并检查您是否意外导入了您不打算导入的“窗口大小”模块并删除了该行代码。这就是简短的答案

如果您有太多文件需要处理,那么您可以暂时删除项目目录中的node_modules内的窗口大小文件夹,警告不要永久删除,请将其保存在安全的地方,并确保关闭metro bundler 窗口,然后再次运行“react-native run-android or ios”,metro 捆绑程序应该会出现错误,但这一次,错误将准确显示项目中的哪个文件有问题,一旦找到它,请删除该行代码,放回窗口大小的文件夹,然后通过运行“cd android && ./gradlew clean”来清理您的项目,关闭metro bundler 并再次运行“react-native run-android or ios”,它应该可以工作,

免责声明,这个答案仅针对这个问题,因为“无法解析模块”错误可能是由很多事情引起的

关于reactjs - react-native : Unable to resolve module `tty` from '' . ../node_modules/window-size/index.js": 模块映射中不存在模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49232344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com