我正在尝试在React Native中构建一个应用程序,并且遇到了一个问题,我的项目在添加图像时会导致崩溃。 Metro捆绑程序说这是因为找不到目录或文件,并给出了错误代码ENOENT
。当我回到更改之前的版本时,应用程序往往会遇到相同的问题,但是当重新启动时,原始版本会正常工作。
我还尝试过重新安装npm,node和yarn,以查看是否存在问题。
这是代码
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import StartScreen from './src/screens/StartScreen/StartScreen'
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<StartScreen />
);
}
}
这是输出
error: bundling failed: Error: ENOENT: no such file or directory, scandir '/Users/Username/TimeTree/src/screens/assets/images'
at Object.readdirSync (fs.js:785:3)
at Object.getDirFiles (/Users/Username/TimeTree/node_modules/metro/src/node-haste/DependencyGraph.js:103:34)
at Map.AssetResolutionCache.dirPath [as _factory] (/Users/Username/TimeTree/node_modules/metro/src/node-haste/AssetResolutionCache.js:41:36)
at Map.get (/Users/Username/TimeTree/node_modules/metro/src/node-haste/lib/MapWithDefaults.js:23:24)
at AssetResolutionCache.resolve (/Users/Username/TimeTree/node_modules/metro/src/node-haste/AssetResolutionCache.js:91:43)
at resolveAsset (/Users/Username/TimeTree/node_modules/metro/src/node-haste/DependencyGraph.js:229:36)
at resolveAssetFiles (/Users/Username/TimeTree/node_modules/metro-resolver/src/resolve.js:463:22)
at resolveFile (/Users/Username/TimeTree/node_modules/metro-resolver/src/resolve.js:349:20)
at resolveFileOrDir (/Users/Username/TimeTree/node_modules/metro-resolver/src/resolve.js:262:22)
at resolveModulePath (/Users/Username/TimeTree/node_modules/metro-resolver/src/resolve.js:184:18)
以下是可能有用的事物的特定版本
Yarn: 1.16.0
npm: 6.9.0
node: 10.15.3
react-native-cli: 2.0.1