Skip to content

npx react-native init fails with latest typescipt template #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
idlework opened this issue Sep 27, 2022 · 2 comments
Closed

npx react-native init fails with latest typescipt template #299

idlework opened this issue Sep 27, 2022 · 2 comments

Comments

@idlework
Copy link

idlework commented Sep 27, 2022

Expected results

What did you expect to happen?
To have installed the latest react-native with Typescript.

Observed results

What happened?
It fails during installation.

Logs

Command line:

❯ npx react-native init *** --template react-native-template-typescript
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from @react-native-community/[email protected]
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     @react-native-community/cli@"^6.0.0" from [email protected]
npm ERR!   react-native@"0.70.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.70.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"18.1.0" from [email protected]
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.70.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/***/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/***/.npm/_logs/2022-09-27T09_14_34_783Z-debug-0.log

Log:

0 verbose cli /Users/***/.nvm/versions/node/v16.17.1/bin/node /Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/bin/npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/Users/***/Development/temp/react-native-typescript/.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:/Users/***/.npmrc Completed in 0ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:/Users/***/.nvm/versions/node/v16.17.1/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 8ms
19 timing npm:load:configload Completed in 8ms
20 timing npm:load:mkdirpcache Completed in 3ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm exec react-native init *** --template [email protected] --ignore-existing
23 verbose argv "exec" "--" "react-native" "init" "***" "--template" "[email protected]" "--ignore-existing"
24 timing npm:load:setTitle Completed in 15ms
25 timing config:load:flatten Completed in 2ms
26 timing npm:load:display Completed in 3ms
27 verbose logfile logs-max:10 dir:/Users/***/.npm/_logs
28 verbose logfile /Users/***/.npm/_logs/2022-09-27T09_14_34_783Z-debug-0.log
29 timing npm:load:logFile Completed in 4ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 33ms
33 silly logfile start cleaning logs, removing 2 files
34 timing arborist:ctor Completed in 1ms
35 silly logfile done cleaning log files
36 http fetch GET 200 https://registry.npmjs.org/react-native 146ms (cache revalidated)
37 timing arborist:ctor Completed in 0ms
38 timing arborist:ctor Completed in 0ms
39 timing idealTree:init Completed in 189ms
40 timing idealTree:userRequests Completed in 1ms
41 silly idealTree buildDeps
42 silly fetch manifest [email protected]
43 http fetch GET 200 https://registry.npmjs.org/react-native 10ms (cache hit)
44 silly fetch manifest [email protected]
45 http fetch GET 200 https://registry.npmjs.org/react 54ms (cache revalidated)
46 timing idealTree Completed in 288ms
47 timing command:exec Completed in 2569ms
48 verbose stack Error: could not resolve
48 verbose stack     at PlaceDep.failPeerConflict (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:549:25)
48 verbose stack     at PlaceDep.place (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:199:21)
48 verbose stack     at new PlaceDep (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:73:10)
48 verbose stack     at /Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:990:31
48 verbose stack     at Array.map (<anonymous>)
48 verbose stack     at Arborist.[buildDepStep] (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:990:8)
48 verbose stack     at async Arborist.buildIdealTree (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
48 verbose stack     at async Promise.all (index 1)
48 verbose stack     at async Arborist.reify (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
48 verbose stack     at async exec (/Users/***/.nvm/versions/node/v16.17.1/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:199:7)
49 verbose cwd /Users/***/Development/temp/react-native-typescript
50 verbose Darwin 21.6.0
51 verbose node v16.17.1
52 verbose npm  v8.15.0
53 error code ERESOLVE
54 error ERESOLVE could not resolve
55 error
56 error While resolving: �[1mundefined�[22m@�[1mundefined�[22m
56 error Found: �[1mreact-native�[22m@�[1m0.67.4�[22m�[2m�[22m
56 error �[2mnode_modules/react-native�[22m
56 error   �[35mpeer�[39m �[1mreact-native�[22m@"�[1m*�[22m" from �[1m@react-native-community/cli�[22m@�[1m6.4.0�[22m�[2m�[22m
56 error   �[2mnode_modules/@react-native-community/cli�[22m
56 error     �[1m@react-native-community/cli�[22m@"�[1m^6.0.0�[22m" from �[1mreact-native�[22m@�[1m0.67.4�[22m
56 error   �[1mreact-native�[22m@"�[1m0.70.1�[22m" from the root project
56 error
56 error Could not resolve dependency:
56 error �[1mreact-native�[22m@"�[1m0.70.1�[22m" from the root project
56 error
56 error Conflicting peer dependency: �[1mreact�[22m@�[1m18.1.0�[22m�[2m�[22m
56 error �[2mnode_modules/react�[22m
56 error   �[35mpeer�[39m �[1mreact�[22m@"�[1m18.1.0�[22m" from �[1mreact-native�[22m@�[1m0.70.1�[22m�[2m�[22m
56 error   �[2mnode_modules/react-native�[22m
56 error     �[1mreact-native�[22m@"�[1m0.70.1�[22m" from the root project
56 error
56 error Fix the upstream dependency conflict, or retry
56 error this command with --force, or --legacy-peer-deps
56 error to accept an incorrect (and potentially broken) dependency resolution.
56 error
56 error See /Users/***/.npm/eresolve-report.txt for a full report.
57 verbose exit 1
58 timing npm Completed in 2657ms
59 verbose unfinished npm timer reify 1664270077140
60 verbose unfinished npm timer reify:loadTrees 1664270077140
61 verbose unfinished npm timer idealTree:buildDeps 1664270077332
62 verbose unfinished npm timer idealTree:#root 1664270077332
63 verbose code 1
64 error A complete log of this run can be found in:
64 error     /Users/***/.npm/_logs/2022-09-27T09_14_34_783Z-debug-0.log

Steps to reproduce

  1. Clean install Node LTS 16.17.1 via NVM
  2. run command npx react-native init *** --template react-native-template-typescript or with added params @6.12.3 --ignore-existing
  3. failed install, see commandline output.

running npm i -g @react-native-community/cli and then run the npx install command does install react-native with the typescript template.

Hope this helps and thank you for you help.

@cortinico
Copy link
Member

Most likely a duplicate of facebook/react-native#34051

npm config set legacy-peer-deps true should do the job for you

@idlework
Copy link
Author

This indeed fixes the issue. Thanks for the help @cortinico.

For others; Do switch back the legacy-peer-deps setting afterwards or else peer dependencies wil be ignored everytime you use npm. See documentation: https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants