react-native init...找不到模块...\template.config

Posted

技术标签:

【中文标题】react-native init...找不到模块...\\template.config【英文标题】:react-native init... cannot find module ...\template.configreact-native init...找不到模块...\template.config 【发布时间】:2019-08-09 10:43:28 【问题描述】:

您好,我在初始化新的 react-native 项目时遇到问题。我已经从 *** 检查了一些类似的问题,但我没有找到任何帮助。

当我尝试使用“react-native init test --verbose”命令初始化新项目时(--verbose 了解更多详细信息) 我收到一个错误:

debug Installing template from react-native@latest
yarn add v1.16.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.0.6: The platform "win32" is incompatible with this module.
info "fsevents@2.0.6" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.9: The platform "win32" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > react-router-scroll-top@0.1.1" has incorrect peer dependency "react-router-dom@^4.2.2".
warning "react-scripts > @typescript-eslint/eslint-plugin@1.6.0" has unmet peer dependency "typescript@*".
warning "react-scripts > @typescript-eslint/parser@1.6.0" has unmet peer dependency "typescript@*".
warning " > eslint-plugin-react-hooks@1.6.1" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0".
warning "react-scripts > @typescript-eslint/eslint-plugin > @typescript-eslint/typescript-estree@1.6.0" has unmet peer dependency "typescript@*".
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning " > eslint-config-airbnb@17.1.1" has unmet peer dependency "eslint@^4.19.1 || ^5.3.0".
warning "eslint-config-airbnb > eslint-config-airbnb-base@13.2.0" has unmet peer dependency "eslint@^4.19.1 || ^5.3.0".
warning " > eslint-config-react-app@3.0.8" has unmet peer dependency "babel-eslint@9.x".
warning " > eslint-config-react-app@3.0.8" has unmet peer dependency "eslint@5.x".
warning " > eslint-config-react-app@3.0.8" has incorrect peer dependency "eslint-plugin-flowtype@2.x".
warning " > eslint-plugin-flowtype@3.13.0" has unmet peer dependency "eslint@>=5.0.0".
warning " > eslint-plugin-import@2.18.2" has unmet peer dependency "eslint@2.x - 6.x".
warning " > eslint-plugin-jsx-a11y@6.2.3" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6".
warning " > eslint-plugin-react@7.14.3" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0".
warning "react-native > metro-react-native-babel-transformer@0.54.1" has unmet peer dependency "@babel/core@*".
[4/4] Building fresh packages...

success Saved 1 new dependency.
info Direct dependencies
└─ react-native@0.60.4
info All dependencies
└─ react-native@0.60.4
Done in 13.10s.
debug Getting config from C:\Users\Lukasz\AppData\Local\Temp\rncli-init-template-8Gdikl\node_modules\react-native\template.config.js
error Error: Cannot find module 'C:\Users\Lukasz\AppData\Local\Temp\rncli-init-template-8Gdikl\node_modules\react-native\template.config'
Require stack:
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\commands\init\template.js
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\commands\init\init.js
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\commands\init\index.js
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\commands\index.js
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\cliEntry.js
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\index.js
- C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\bin.js
error EBUSY: resource busy or locked, rmdir 'C:\xampp\htdocs\projekty\19-08-sie\test'
Error: EBUSY: resource busy or locked, rmdir 'C:\xampp\htdocs\projekty\19-08-sie\test'
    at Object.rmdirSync (fs.js:693:3)
    at rmdirSync (C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\fs-extra\lib\remove\rimraf.js:276:13)
    at Object.rimrafSync [as removeSync] (C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\fs-extra\lib\remove\rimraf.js:252:7)
    at Object.initialize [as func] (C:\Users\Lukasz\AppData\Local\Yarn\Data\global\node_modules\@react-native-community\cli\build\commands\init\init.js:292:26)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)

我试过了: - 清除 npm 缓存 - 重新安装 react-native

【问题讨论】:

问题解决了吗? 【参考方案1】:

我有同样的错误。为作品安装 react-native-cli。

yarn global add react-native-cli

npm i -g react-native-cli

【讨论】:

【参考方案2】:

问题是服务器 xampp 的位置。 C:// 下的所有第一级文件夹都需要管理员权限才能更新或删除,我建议在另一个地方安装 xampp,或者以管理员权限运行控制台。

【讨论】:

我尝试使用管理员权限和/或不同的本地化安装 - 得到相同的错误

以上是关于react-native init...找不到模块...\template.config的主要内容,如果未能解决你的问题,请参考以下文章

react-native出现编译模块找不到

将 react-native 升级到最新版本 0.61.4 后找不到以下原生模块

当我运行“npx react-native start”时找不到模块“@expo/metro-config”

react-native 捆绑失败:错误:找不到模块 /metro-react-native-babel-transformer/src/index.js

找不到模块'cx_Freeze__init__'

__init__.py 找不到本地模块