我正在尝试使用 CLI 使用 React Native 样板,但每次尝试时都会显示此错误。我不知道这里需要修复什么。如果我使用react-native@latest init,它会起作用,但它将被弃用。 我想使用react-native-community/cli@latest init。
npx react-native-community/cli@latest init MyApp --template file:///E:/React%20Native/rnboilerplate
npm error code ENOENT
npm error syscall open
npm error path E:\React Native\RNTesting\react-native-community\cli@latest\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'E:\React Native\RNTesting\react-native-community\cli@latest\package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2024-08-20T03_37_29_814Z-debug-0.log
我重新阅读了自述文件中的react-native-community/cli的文档 react-native-community/cli 启动它的 npx @react-native-community/cli@latest init MyApp 但在 react-native-community/cli/commands 中命令的开头没有“@”
npx react-native-community/cli@latest init MyApp
但使用本地存储库 E://React Native/RNTesting/ 仍然存在问题,无法正常工作,我使用 GitHub 存储库解决了这个问题。