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

时间:2019-08-09 10:43:28

标签: react-native

嗨,我在初始化新的react-native项目时遇到问题。我已经检查了stackoverflow的一些类似问题,但没有找到任何有用的方法。

当我尝试使用“ 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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

我有同样的错误。为工程安装react-native-cli。

yarn global add react-native-cli

npm i -g react-native-cli