1

whenever I create a new project then it throws the following Error. I did update any settings. everything was working fine before yesterday. Here is my issue.

[1/4] Resolving packages...
error Couldn't find package **"@typescript-eslint/parser@^4.22.1"** required by **"@react-native-community/eslint-config"** on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
E:\example\project\node_modules\execa\index.js:174
                err = new Error(`Command failed: ${joinedCmd}${output}`);
                      ^

Error: Command failed: yarn add -D @babel/core @babel/runtime @react-native-community/eslint-config eslint jest babel-jest metro-react-native-babel-preset react-test-renderer@17.0.1
    at makeError (E:\example\project\node_modules\execa\index.js:174:9)
    at E:\example\project\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async generateProject (E:\example\project\node_modules\@react-native-community\cli\build\commands\init\initCompat.js:128:3)
    at async Object.initCompat (E:\example\project\node_modules\@react-native-community\cli\build\commands\init\initCompat.js:105:3) {
  code: 1,
  stdout: null,
  stderr: null,
  failed: true,
  signal: null,
  cmd: 'yarn add -D @babel/core @babel/runtime @react-native-community/eslint-config eslint jest babel-jest metro-react-native-babel-preset react-test-renderer@17.0.1',
  timedOut: false,
  killed: false
}

I did all remove a node, update node, removed react-native-CLI, and update it and it was fixed for some time. but I was unable to install any package.

it's now day 2 and I am stuck here.

Surender Kumar
  • 1,152
  • 16
  • 17
Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47

3 Answers3

1

Before running:

react-native init

Try running

npm install @typescript-eslint/parser@^4.22.1  

I hope it resolves the issue.

If the issue persists try clearing cache with:

npm cache clean --force
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
OsamaD
  • 453
  • 7
  • 12
  • I did this but it then gives another error. I create a clean setup and env variable setup. but it's going worse. tried yarn. but it has another issue, – Engr.Aftab Ufaq Jul 03 '21 at 07:33
  • yes. I delete them. reinstall. then update. clear temp files. delete node modules manually. but still, I am getting issues. – Engr.Aftab Ufaq Jul 03 '21 at 07:44
  • npm ERR! invalid json response body at http://registry.npmjs.org/chalk reason: Unexpected token : in JSON at position 6551 – Engr.Aftab Ufaq Jul 03 '21 at 07:47
  • E:\example>npx react-native init newproee npm ERR! code FETCH_ERROR npm ERR! errno FETCH_ERROR npm ERR! invalid json response body at http://registry.npmjs.org/react-native reason: Unexpected token } in JSON at position 79493 npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\dell\AppData\Local\npm-cache\_logs\2021-07-03T07_47_40_258Z-debug.log – Engr.Aftab Ufaq Jul 03 '21 at 07:47
  • okay try running npm config set registry "https://registry.npmjs.org" – OsamaD Jul 03 '21 at 07:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/234468/discussion-between-aftab-amin-and-osamad). – Engr.Aftab Ufaq Jul 03 '21 at 07:50
1

Emm... i had a super similar error, i just switched to a stable version of node v18.17.1, and yeah it worked.

Ev357
  • 26
  • 4
0

Finally after search for a long time. I found a solution. just go to the network setting and turn off automatic proxy setting detection.

Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47