How do I fix this issue in react native project - "npm ERR! Invalid tag name ">=^16.8.1"" this issue? - react-native

I am getting this error when install the node modules(npm install). Why this issue happening in react native project? Is this related to node version ?
Error :
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name ">=^16.8.1":
Tags may not have any characters that encodeURIComponent encodes. npm
ERR! A complete log of this run can be found in:
/Users/abcdef/.npm/_logs/2021-08-02T05_31_11_609Z-debug.log
Error Log (debug.log)
109 verbose stack Error: Invalid tag name ">=^16.8.1": Tags may not have any characters that encodeURIComponent encodes.
109 verbose stack at invalidTagName (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:89:15)
109 verbose stack at fromRegistry (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:343:13)
109 verbose stack at Function.resolve (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:80:12)
109 verbose stack at Arborist.[nodeFromEdge] (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:949:37)
109 verbose stack at async Arborist.[loadPeerSet] (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:1170:23)
109 verbose stack at async Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:886:11)
109 verbose stack at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
109 verbose stack at async Promise.all (index 1)
109 verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/reify.js:134:5)
109 verbose stack at async Install.install (/usr/local/lib/node_modules/npm/lib/install.js:150:5)
110 verbose cwd /Users/abcde/Project/XXX/Workspace/xyz-app
111 verbose Darwin 19.6.0
112 verbose argv "/usr/local/Cellar/node/16.4.2/bin/node" "/usr/local/bin/npm" "i"
113 verbose node v16.4.2
114 verbose npm v7.20.2
115 error code EINVALIDTAGNAME
116 error Invalid tag name ">=^16.8.1": Tags may not have any characters that encodeURIComponent encodes.
117 verbose exit 1

I got the solution for this issue. We can fix this issue in two ways,
Downgrade the npm version(In my case, I have downgraded it to 6.14.14 after that it's working fine.)
npm install -g npm#6.14.14
In the terminal, navigate to your project root directory and run this
npm install --legacy-peer-deps

Related

Npm install fails due to invalid version

So as part of some work I'm doing, I am trying to get the packages we use in our application up to the latest versions as when running npm audit there were a significant amount of vulnerabilities.
One of the the things it comes up saying to install mocha#9.2.2
I have been trying to do this but I get an error saying:
npm ERR! Invalid version: ^6.0.1
I have no idea what this is referring to as in the package.json there are no packages that have this version and when I look at the debug log I just get:
207 verbose stack TypeError: Invalid Version: ^6.0.1
207 verbose stack at new SemVer (C:\Program Files\nodejs\node_modules\npm\node_modules\semver\classes\semver.js:38:13)
207 verbose stack at compare (C:\Program Files\nodejs\node_modules\npm\node_modules\semver\functions\compare.js:3:32)
207 verbose stack at Object.gte (C:\Program Files\nodejs\node_modules\npm\node_modules\semver\functions\gte.js:2:30)
207 verbose stack at CanPlaceDep.checkCanPlaceCurrent (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\can-place-dep.js:173:51)
207 verbose stack at CanPlaceDep.checkCanPlace (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\can-place-dep.js:157:27)
207 verbose stack at new CanPlaceDep (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\can-place-dep.js:114:26)
207 verbose stack at PlaceDep.place (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\place-dep.js:121:19)
207 verbose stack at new PlaceDep (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\place-dep.js:71:10)
207 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\build-ideal-tree.js:949:31
207 verbose stack at Array.map (<anonymous>)
208 verbose cwd C:\tfs\Agility\Branches\AgilityMakeover\Client\Web\AgilityItemViewer
209 verbose Windows_NT 10.0.19044
210 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "mocha#9.2.2"
211 verbose node v16.14.0
212 verbose npm v8.3.1
213 error Invalid Version: ^6.0.1
214 verbose exit 1
So I have no idea what this could be referring to, as far as I can tell there is no package reference. I have tried just removing the package-lock.json file and the deleting the node_modules folder and running npm install again but I keep getting this error. But I have no clue on how to progress, any advice would be appreciated
What eventually seemed to solve the problem for me was going through the list of packages shown i.e semver, can-place-dep etc and updating them all manually by doing: npm update semver and so on. I then deleted my package-lock.json and node_modules folder again and did npm install. After this I stopped getting the invalid version error. Hopefully this can help someone else if they end up having the same issue I had
Try this
Delete npm_modules folder
Delete the package.json.lock file
run npm cache clean --force
And try npm install

How can I fix these errors with npm run build on the Next.js default project?

I'm a graphic student trying to learn something further than classic HTML/CSS.
I want to build the default Next.js app, which you can get by npm create-next-app filename.
It certainly works when npm run dev. I can see the index page on localhost:3000.
But npm run build gets:
% npm run build
> test#0.1.0 build /Users/minori/Documents/portfolio/test
> next build
info - Checking validity of types
Failed to compile.
./pages/index.js
8:7 Error: Missing "key" prop for element in array react/jsx-key
/*almost same messages repeated for every line*/
63:13 Error: Missing "key" prop for element in array react/jsx-key
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test#0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/minori/.npm/_logs/2022-02-25T17_53_21_317Z-debug.log
And here is the debug log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm#6.14.15
3 info using node#v14.17.6
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle test#0.1.0~prebuild: test#0.1.0
6 info lifecycle test#0.1.0~build: test#0.1.0
7 verbose lifecycle test#0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle test#0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/minori/Documents/portfolio/test/node_modules/.bin:/Users/minori/.npm-global/lib/node_modules/n/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/minori/bin:/opt/osxws/bin:/opt/osxws/sbin
9 verbose lifecycle test#0.1.0~build: CWD: /Users/minori/Documents/portfolio/test
10 silly lifecycle test#0.1.0~build: Args: [ '-c', 'next build' ]
11 silly lifecycle test#0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle test#0.1.0~build: Failed to exec build script
13 verbose stack Error: test#0.1.0 build: `next build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:400:28)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:400:28)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid test#0.1.0
15 verbose cwd /Users/minori/Documents/portfolio/test
16 verbose Darwin 20.3.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v14.17.6
19 verbose npm v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error test#0.1.0 build: `next build`
22 error Exit status 1
23 error Failed at the test#0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I already tried npm install -g npm-rm -rf node_modules-npm install, re-installing node.js, npm cache clear --force and rm package-lock.json.
Does anyone know what the problem is?
What else can I try now?
It's not you, there is an issue logged with eslint-plugin-react that create-next-app uses, if they haven't already done so (try npm create-next-app again) you can find eslint-plugin-react in your package.json to version 7.29.1
You can see the Vercel team noting the change and the eslint-plugin-react author's responding
https://github.com/yannickcr/eslint-plugin-react/issues/3215#issuecomment-1051115159

Skip a package when running `npm -g outdated`

I have a package that I manually updated in order to have multiple versions of the same tool running (as explained here).
Now, when I execute npm -g outdated, I am getting the following output:
$ npm -g outdate
npm notice
npm notice New minor version of npm available! 7.18.1 -> 7.20.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.20.1
npm notice Run npm install -g npm#7.20.1 to update!
npm notice
npm ERR! code ENOVERSIONS
npm ERR! No versions available for ask-cli-1
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/b/.npm/_logs/2021-07-24T13_02_50_529Z-debug.log
Here are the contents of the log, edited for brevity:
0 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', '-g', 'update' ]
1 info using npm#7.18.1
2 info using node#v16.4.1
...
9 timing config:load:file:/usr/local/lib/node_modules/ask-cli-1/.npmrc Completed in 0ms
...
33 silly fetch manifest ask-cli-1#*
34 http fetch GET 200 https://registry.npmjs.org/ask-cli-1 38ms (cache hit)
...
40 silly placeDep ROOT ask-cli-1# OK for: want: *
...
316 timing idealTree:node_modules/ask-cli-1 Completed in 0ms
...
1338 verbose stack ask-cli-1: No versions available for ask-cli-1
1338 verbose stack at pickManifest (/usr/local/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:140:25)
1338 verbose stack at module.exports (/usr/local/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:187:16)
1338 verbose stack at /usr/local/lib/node_modules/npm/node_modules/pacote/lib/registry.js:118:26
1338 verbose stack at async Arborist.[nodeFromEdge] (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:936:19)
1338 verbose stack at async Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:882:11)
1338 verbose stack at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
1338 verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/#npmcli/arborist/lib/arborist/reify.js:134:5)
1338 verbose stack at async Update.update (/usr/local/lib/node_modules/npm/lib/update.js:72:5)
1339 verbose cwd /usr/local/lib/node_modules/ask-cli-1
1340 verbose Darwin 20.5.0
1341 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "-g" "update"
1342 verbose node v16.4.1
1343 verbose npm v7.18.1
1344 error code ENOVERSIONS
1345 error No versions available for ask-cli-1
1346 verbose exit 1
Is there a way to avoid npm looking for a version of ask-cli-1?
You can't exclude a package with npm outdated.
But I recomemnd this package: check-outdated
In your case npm i -g check-outdated
Then:
check-outdated --ignore-packages ask-cli-1 --columns name,type,current,latest,changes

Keystone JS (generator-keystone) npm install fails

I have installed Keystone with Yeoman Generator.
yo keystone command runs without errors, but the following npm install finishes with error:
npm ERR! Unexpected end of JSON input while parsing near '...6.4","react":"^16.8.6'
Data from debug log
2317 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...6.4","react":"^16.8.6'
2317 verbose stack at JSON.parse (<anonymous>)
2317 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
2317 verbose stack at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50)
2317 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
How can I fix that?

NPM outdated throws npm ERR! Not implemented yet

Since I updated to npm 6.9.0 (node 8.12.0) I'm getting this error when running npm outdated:
$ npm outdated
npm ERR! Not implemented yet
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jgallaso/.npm/_logs/2019-04-10T11_13_48_791Z-debug.log
The logs shows this error:
173 verbose stack Error: Not implemented yet
173 verbose stack at Object.packument (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/pacote/lib/fetchers/remote.js:12:22)
173 verbose stack at Object.Fetcher#packument [as packument] (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/genfun/lib/genfun.js:15:38)
173 verbose stack at packument (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:17:18)
173 verbose stack at pinflight (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/pacote/packument.js:23:12)
173 verbose stack at /Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:29:24
173 verbose stack at Promise._execute (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/debuggability.js:313:9)
173 verbose stack at Promise._resolveFromExecutor (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:483:18)
173 verbose stack at new Promise (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:79:10)
173 verbose stack at _inflight (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:28:25)
173 verbose stack at /Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:22:14
173 verbose stack at tryCatcher (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
173 verbose stack at Promise._settlePromiseFromHandler (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
173 verbose stack at Promise._settlePromise (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
173 verbose stack at Promise._settlePromiseCtx (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:606:10)
173 verbose stack at _drainQueueStep (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:142:12)
173 verbose stack at _drainQueue (/Users/jgallaso/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:131:9)
When I run npm outdated on a specific package, for instance eslint I get the proper output:
$ npm outdated eslint
Package Current Wanted Latest Location
eslint 5.15.1 5.16.0 5.16.0
What's happening here? Is it due to some buggy package or a bug NPM itself?
As a temporal solution you can install the latest npm:
npm i npm -g
npm i then npm update worked for me.