Can't use npm install after I updated the version of all nestjs dependencies in my package.json - npm

I have created a new nestjs project and installed several additional standard packages. In the console it said that the packages are outdated and there are 7 red vulnerabilities.
The suggested command npm audit fix --force did't help - there were still 4 red vulnerabilities after that.
I found a command that updates my packages to the latest versions:
npm install -g npm-check-updates
ncu -u
npm install
Now I can't use npm install:
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #nestjs/typeorm#8.0.4
npm ERR! Found: typeorm#0.3.6
npm ERR! node_modules/typeorm
npm ERR! typeorm#"^0.3.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typeorm#"^0.2.34" from #nestjs/typeorm#8.0.4
npm ERR! node_modules/#nestjs/typeorm
npm ERR! #nestjs/typeorm#"^8.0.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typeorm#0.2.45
npm ERR! node_modules/typeorm
npm ERR! peer typeorm#"^0.2.34" from #nestjs/typeorm#8.0.4
npm ERR! node_modules/#nestjs/typeorm
npm ERR! #nestjs/typeorm#"^8.0.4" 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.
I deleted node_modules as well as the package-lock.json and then forced the installation with npm install --force. But I get again the message about severity vulnerabilities:
npm install --force
npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: #nestjs/typeorm#8.0.4
npm WARN Found: typeorm#0.3.6
npm WARN node_modules/typeorm
npm WARN typeorm#"^0.3.6" from the root project
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer typeorm#"^0.2.34" from #nestjs/typeorm#8.0.4
npm WARN node_modules/#nestjs/typeorm
npm WARN #nestjs/typeorm#"^8.0.4" from the root project
npm WARN
npm WARN Conflicting peer dependency: typeorm#0.2.45
npm WARN node_modules/typeorm
npm WARN peer typeorm#"^0.2.34" from #nestjs/typeorm#8.0.4
npm WARN node_modules/#nestjs/typeorm
npm WARN #nestjs/typeorm#"^8.0.4" from the root project
added 823 packages, and audited 824 packages in 29s
84 packages are looking for funding
run `npm fund` for details
7 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
I am going in circles and do not understand how to solve the problem. And especially which version I need to use that has no red security issues?
My package.json file now looks like this:
{
"name": "api",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^8.4.5",
"#nestjs/core": "^8.4.5",
"#nestjs/platform-express": "^8.4.5",
"#nestjs/typeorm": "^8.0.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.5",
"sqlite3": "^5.0.8",
"typeorm": "^0.3.6"
},
"devDependencies": {
"#nestjs/cli": "^8.2.6",
"#nestjs/schematics": "^8.0.11",
"#nestjs/testing": "^8.4.5",
"#types/express": "^4.17.13",
"#types/jest": "27.5.1",
"#types/node": "^17.0.35",
"#types/supertest": "^2.0.12",
"#typescript-eslint/eslint-plugin": "^5.26.0",
"#typescript-eslint/parser": "^5.26.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.0",
"prettier": "^2.6.2",
"source-map-support": "^0.5.21",
"supertest": "^6.2.3",
"ts-jest": "^28.0.3",
"ts-loader": "^9.3.0",
"ts-node": "^10.8.0",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.7.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
Why do I get an indication that I am using typeorm#"^0.2.34" even though my package.json file specifies a newer version "typeorm": "^0.3.6"? This is also the latest version at the moment.
PS: If I change the typorm version back to 0.2.34 or 0.2, I can use npm install again but I get the red "7 high severity vulnerabilities" message.

Same issue for me. Using npm install --legacy-peer-deps seems to fix the issue however vulnerabilities remains.

Hello I just got the some problem as yours it's because the nest and npm commands getting blocked so try to allow it from Windows PowerShell by following these steps here

update to the latest npm version by running this command
npm i -g npm#latest

Related

How to read ERESOLVE in npm audit fix?

Here is the output I have after getting audit warnings after installing an npm package:
$ npm audit fix
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: eslint-config-standard-with-typescript#21.0.1
npm ERR! Found: #typescript-eslint/eslint-plugin#5.46.1
npm ERR! node_modules/#typescript-eslint/eslint-plugin
npm ERR! dev #typescript-eslint/eslint-plugin#"^5.46.1" from the root project
npm ERR! peerOptional #typescript-eslint/eslint-plugin#"^5.0.0" from eslint-plugin-unused-imports#2.0.0
npm ERR! node_modules/eslint-plugin-unused-imports
npm ERR! dev eslint-plugin-unused-imports#"^2.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #typescript-eslint/eslint-plugin#"^4.0.1" from eslint-config-standard-with-typescript#21.0.1
npm ERR! node_modules/eslint-config-standard-with-typescript
npm ERR! dev eslint-config-standard-with-typescript#"^21.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #typescript-eslint/eslint-plugin#4.33.0
npm ERR! node_modules/#typescript-eslint/eslint-plugin
npm ERR! peer #typescript-eslint/eslint-plugin#"^4.0.1" from eslint-config-standard-with-typescript#21.0.1
npm ERR! node_modules/eslint-config-standard-with-typescript
npm ERR! dev eslint-config-standard-with-typescript#"^21.0.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!
npm ERR! For a full report see:
npm ERR! /Users/lancepollard/.npm/_logs/2023-01-02T17_19_47_490Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/lancepollard/.npm/_logs/2023-01-02T17_19_47_490Z-debug-0.log
That came after running npm audit fix --force a few times, after getting this:
$ npm install eslint-plugin-unused-imports --save-dev
added 2 packages, and audited 379 packages in 4s
107 packages are looking for funding
run `npm fund` for details
5 high severity vulnerabilities
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Any ideas what I should be doing here to resolve and get a successful install?
My package.json is:
{
"main": "./host",
"type": "module",
"scripts": {
"build": "tsc && tsc-alias",
"watch": "concurrently --kill-others \"tsc -w\" \"tsc-alias -w\"",
"lint": "eslint --ext .ts ./make",
"lint:fix": "npm run lint -- --fix",
"test": "node host/task/build"
},
"devDependencies": {
"#trivago/prettier-plugin-sort-imports": "^4.0.0",
"#types/glob": "^8.0.0",
"#types/lodash": "^4.14.191",
"#types/node": "^18.11.17",
"#typescript-eslint/eslint-plugin": "^5.46.1",
"#typescript-eslint/parser": "^5.46.1",
"concurrently": "^7.6.0",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.24.1",
"eslint-plugin-n": "^15.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-sort-exports": "^0.8.0",
"eslint-plugin-sort-keys": "^2.3.5",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"eslint-plugin-unused-imports": "^2.0.0",
"prettier": "2.8.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.2",
"typescript": "^4.9.4"
},
"dependencies": {
"#lancejpollard/pretty-compact-json.js": "^0.2.0",
"chalk": "^5.2.0",
"glob": "^8.0.3",
"lodash": "^4.17.21",
"source-map": "^0.7.4"
}
}
Now I have rm -rf node_modules, and when I do npm install again, it shows the same error....
I had the same problem. Deleting the package-lock.json and the node_modules, and then running npm install solved my issue.
I hope it helps.

Unable to resolve module react-native-fs

I'm learning react native and building and app that use the camera and it works fine.
Now I'm trying to make image classification but I'm getting this error after installing:
#tensorflow/tfjs-react-native --legacy-peer-deps
I get this:
Unable to resolve module react-native-fs from
/Users/myuser/ALPR/node_modules/#tensorflow/tfjs-react-native/dist/bundle_resource_io.js:
react-native-fs could not be found within the project or in these
directories: node_modules
I don't know what should I do, I tried installing react-native-fs but I got this:
npm install react-native-fs npm ERR! code ERESOLVE npm ERR! ERESOLVE
could not resolve npm ERR! npm ERR! While resolving:
#tensorflow/tfjs-react-native#0.8.0 npm ERR! Found:
#tensorflow/tfjs-backend-cpu#3.19.0 npm ERR!
node_modules/#tensorflow/tfjs-backend-cpu npm ERR!
#tensorflow/tfjs-backend-cpu#"3.19.0" from #tensorflow/tfjs#3.19.0 npm
ERR! node_modules/#tensorflow/tfjs npm ERR!
#tensorflow/tfjs#"^3.19.0" from the root project npm ERR!
#tensorflow/tfjs-backend-cpu#"3.19.0" from
#tensorflow/tfjs-backend-webgl#3.19.0 npm ERR!
node_modules/#tensorflow/tfjs-backend-webgl npm ERR!
#tensorflow/tfjs-backend-webgl#"3.19.0" from #tensorflow/tfjs#3.19.0
npm ERR! node_modules/#tensorflow/tfjs npm ERR!
#tensorflow/tfjs#"^3.19.0" from the root project npm ERR! npm ERR!
Could not resolve dependency: npm ERR! peer
#tensorflow/tfjs-backend-cpu#"~3.11.0" from
#tensorflow/tfjs-react-native#0.8.0 npm ERR!
node_modules/#tensorflow/tfjs-react-native npm ERR!
#tensorflow/tfjs-react-native#"^0.8.0" from the root project npm ERR!
npm ERR! Conflicting peer dependency:
#tensorflow/tfjs-backend-cpu#3.11.0 npm ERR!
node_modules/#tensorflow/tfjs-backend-cpu npm ERR! peer
#tensorflow/tfjs-backend-cpu#"~3.11.0" from
#tensorflow/tfjs-react-native#0.8.0 npm ERR!
node_modules/#tensorflow/tfjs-react-native npm ERR!
#tensorflow/tfjs-react-native#"^0.8.0" 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/macmac/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/macmac/.npm/_logs/2022-08-22T12_14_25_319Z-debug-0.log
I'm using this tutorial: https://www.bam.tech/article/how-to-recognize-real-time-object-in-reactnative-for-dummies
Hopefully somebody can help me with this.
Thanks
This is the package.json
{
"name": "alpr",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#react-native-async-storage/async-storage": "~1.17.3",
"#tensorflow/tfjs": "^3.19.0",
"#tensorflow/tfjs-react-native": "^0.8.0",
"expo": "~46.0.8",
"expo-camera": "~12.3.0",
"expo-gl": "~11.4.0",
"expo-gl-cpp": "~11.4.0",
"expo-media-library": "~14.2.0",
"expo-sharing": "~10.3.0",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-native": "0.69.4"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
Finally I solved this by deleting the folder node_modules and then I used yarn install instead of npm.

How to get npm to install a single package?

I have downloaded an npm project, and npm install fails with a bunch of dependency errors. In an attempt to find the problem, I've tried installing each dependency individually with, e.g., npm install react, but the command ignores the single argument and instead gives the same errors as trying to install the entire project. In desperation I tried the example from https://docs.npmjs.com/cli/v8/commands/npm-install: 'npm install sax`, where sax has nothing to do with the project, and it still fails.
package.json is:
{
"name": "graphiql-explorer-example",
"homepage": "https://onegraph.github.io/graphiql-explorer-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"graphiql": "^0.12.0",
"graphql": "^14.1.1",
"graphiql-explorer": "^0.6.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"flow": "flow",
"deploy": "gh-pages -d build",
"predeploy": "yarn build",
"prettier": "prettier --write \"src/**/*.js\" \"docs/**/*.md\" README.md"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"flow-bin": "^0.91.0",
"gh-pages": "^2.0.1"
},
"description": "Example usage of [OneGraph](https://www.onegraph.com)'s open source [GraphiQL explorer](https://github.com/OneGraph/graphiql-explorer).",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/OneGraph/graphiql-explorer-example.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/OneGraph/graphiql-explorer-example/issues"
}
}
The error messages are:
> npm install react
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: graphiql-explorer-example#0.1.0
npm ERR! Found: graphql#14.1.1
npm ERR! node_modules/graphql
npm ERR! graphql#"^14.1.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer graphql#"^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0" from graphiql#0.12.0
npm ERR! node_modules/graphiql
npm ERR! graphiql#"^0.12.0" 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.
The log file (excluding a pile of "timing" and "silly" messages) is:
1 info using npm#8.8.0
2 info using node#v16.14.2
22 verbose title npm install sax
23 verbose argv "install" "sax"
41 http fetch GET 200 https://registry.npmjs.org/graphiql 144ms (cache revalidated)
43 http fetch GET 200 https://registry.npmjs.org/graphql 47ms (cache revalidated)
47 verbose stack Error: unable to resolve dependency tree
As you can see, npm parses the "sax" argument correctly on line 23, but then ignores it and tries to install graphiql instead.
How can I get npm to install a single package, such as the latest version of react, instead of trying to install all of the dependencies for graphiql-explorer?
the problem here is the peer dependencies of "sax"
there are some ways to avoid checking peer dependency.
Method 1
npm install <package name> --force
or
npm install <package name> --legacy-peer-deps
but it is not recommended,
Adding --legacy-peer-deps to your npm installation will bypass peerDependency auto-installation, but this may result in conflicts due to potentially breaking changes
try to resove conflicts manually, by getting the peer dependency details using
npm info name-of-module peerDependencies
for more information refer: What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case?
There is a fix for running the npm install command.
$ npm install
According to your error message when running the installation command:
npm ERR! ERESOLVE unable to resolve dependency tree
It states that some dependencies are incompatible with others. To fix this, you need to run the installation command with the following flag.
$ npm install --legacy-peer-deps
This should resolve the issue of the dependencies being incompatible with each other.
In conclusion, the issue was that the dependencies were incompatible with each other. However, there is a fix!
$ npm install --legacy-peer-deps

Can't upgrade React-Native project due dependencies

I am trying to update my RN project from 0.62.2 to the latest one (currently 0.63.3).
I am just running npm update and get errors:
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"16.13.1" from react-native#0.63.3
npm ERR! node_modules/react-native
npm ERR! react-native#"^0.63.3" 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.
Before running npm update I had ran npx npm-check-updates -u and got the following:
#react-native-community/netinfo ^5.9.5 → ^5.9.9
#react-navigation/drawer ^5.8.6 → ^5.11.4
#react-navigation/native ^5.7.1 → ^5.8.10
#react-navigation/stack ^5.7.1 → ^5.12.8
#types/react ^16.9.43 → ^17.0.0
amazon-cognito-identity-js ^3.3.3 → ^4.5.5
aws-amplify ^3.0.21 → ^3.3.10
axios ^0.19.2 → ^0.21.0
graphql ^0.11.7 → ^15.4.0
graphql-tag ^2.10.4 → ^2.11.0
moment-timezone ^0.5.31 → ^0.5.32
react ^16.11.0 → ^17.0.1
react-native ^0.62.2 → ^0.63.3
react-native-base64 0.0.2 → 0.1.0
react-native-gesture-handler ~1.5.0 → ~1.9.0
react-native-reanimated ~1.4.0 → ~1.13.2
react-native-safe-area-context ^0.7.3 → ^3.1.9
react-native-screens 2.0.0-alpha.12 → 2.15.0
react-native-simple-crypto ^0.2.13 → ^0.2.15
react-native-vector-icons ^6.7.0 → ^7.1.0
react-navigation ^4.4.0 → ^4.4.3
#babel/core 7.8.7 → 7.12.9
#babel/runtime 7.8.7 → 7.12.5
babel-jest 24.9.0 → 26.6.3
metro-react-native-babel-preset 0.56.4 → 0.64.0
react-test-renderer 16.9.0 → 17.0.1
OK, I summarise from the error that react#^17.0.1 is wrong for react-native#0.63.3 which requires react#16.13.1 but this was produced by npx npm-check-updates -u - why it makes incompatible deps tree?..
If I change manually react version to "^16.0.0", npm install fails with:
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"16.13.1" from react-native#0.63.3
npm ERR! node_modules/react-native
npm ERR! react-native#"^0.63.3" from the root project
Why "react#16.14.0"?! From where?
I just can't understand how all this s..tuff works.. Please, suggest.
My current package.json:
{
"name": "Proj",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-native-community/netinfo": "^5.9.9",
"#react-navigation/drawer": "^5.11.4",
"#react-navigation/native": "^5.8.10",
"#react-navigation/stack": "^5.12.8",
"#types/react": "^17.0.0",
"amazon-cognito-identity-js": "^4.5.5",
"aws-amplify": "^3.3.10",
"axios": "^0.21.0",
"graphql": "^15.4.0",
"graphql-tag": "^2.11.0",
"i18n-js": "^3.8.0",
"moment-timezone": "^0.5.32",
"react": "^16.0.0",
"react-native": "^0.63.3",
"react-native-avatar-social": "0.0.3",
"react-native-base64": "0.1.0",
"react-native-gesture-handler": "~1.9.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-localize": "^2.0.1",
"react-native-reanimated": "~1.13.2",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "2.15.0",
"react-native-simple-crypto": "^0.2.15",
"react-native-tab-view": "^2.15.2",
"react-native-tab-view-viewpager-adapter": "^1.1.0",
"react-native-uuid-generator": "^6.1.1",
"react-native-vector-icons": "^7.1.0",
"react-native-video": "^4.4.5",
"react-native-viewpager": "^0.2.13",
"react-native-zeroconf": "github:atlascoder/react-native-zeroconf",
"react-navigation": "^4.4.3",
"rn-fetch-blob": "^0.12.0"
},
"devDependencies": {
"#babel/core": "7.12.9",
"#babel/runtime": "7.12.5",
"babel-jest": "26.6.3",
"metro-react-native-babel-preset": "0.64.0",
"react-test-renderer": "17.0.1"
},
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
}
UPDATE
Following #anthony-marino suggestion I made manual dependencies update by update helper, and the I returned to the issue that moved my to upgrade!!
npm ERR! Found: react#16.13.1
npm ERR! node_modules/react
npm ERR! react#"16.13.1" from the root project
npm ERR! peer react#"^16.0" from #react-native-community/viewpager#4.2.1
npm ERR! node_modules/#react-native-community/viewpager
npm ERR! peer #react-native-community/viewpager#"*" from react-native-tab-view-viewpager-adapter#1.1.0
npm ERR! node_modules/react-native-tab-view-viewpager-adapter
npm ERR! react-native-tab-view-viewpager-adapter#"^1.1.0" from the root project
npm ERR! 15 more (#react-navigation/core, #react-navigation/drawer, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"16.11.0" from react-native-zeroconf#0.12.3
npm ERR! node_modules/react-native-zeroconf
npm ERR! react-native-zeroconf#"github:atlascoder/react-native-zeroconf" from the root project
npm ERR!
And the thing that runs me out..
I have a component from #react-native-community/viewpager and why if it requires peerDep react#"^16.0" - why it doesn't accept react#16.13.1. The ^16.0 means all fresher that 16.*, doesn't it?! When I check ^16.0 on npm semver calculator - it shows me 16.13.1 as suitable..
WORKAROUND
On trapping to this trouble while update:
Delete node_modules and package-lock.json
npm i
When npm i fails - remove failing dependencies
After completion of npm i - manually install removed dependencies
From your logs: react-native 0.63.3 needs react#"16.13.1", but found react#"^17.0.1". Just downgrade your react via npm install react#16.13.1 and try npm install again. It should work without errors. If you run npm outdated you'll see that "react" is outdated. But it's unlikely that you're going to have all your packages in the latest version.
so I've also run into this problem when I migrated from RN 0.63.1 to 0.64.1 so I solved it in this way:
Step run npx react-native upgrade for me it updated react and react-native
Then I've updated these dependencies mannually:
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "17.0.1"
you could use this tool to see what changes did these command npx react-native upgrade and what changes you have to do it manualy
https://react-native-community.github.io/upgrade-helper/?from=0.63.1&to=0.64.1
Then run npm install --force to update package-lock.json with new dependency that you've added manually.
If you have tests with Jest probably then you have to adjust a few things as well go to jest.configs.js and make sure you have here react-native and #react-native as well
transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native|#react-native|#react-native-community)',
],
and probably you'll have some problem with these mock as well
// The old way
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
// Here path was updated
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
Now you should be good to go, this example was for upgrading RN from 0.63.1 to 0.64.1 but it could work for you as well.
p.s I'm using node -v 14.15.4 and npm -v 7.7.6 you may have less problem if you're using npm v6
This solved my problem.
npm install #react-native-community/masked-view --force
I had to use :
npm i --legacy-peer-deps

npm install -g #angular/cli failing with syntax error

I have a jenkins job that runs on a centos 7 container.
Once the container is up the jenkins job runs a script that
executes
npm install -g #angular/cli
This has worked for about an year but today it started failing:
/usr/bin/ng -> /usr/lib/node_modules/#angular/cli/bin/ng
> #angular/cli#8.0.4 postinstall /usr/lib/node_modules/#angular/cli
> node ./bin/postinstall/script.js
/usr/lib/node_modules/#angular/cli/bin/postinstall/analytics-prompt.js:8
(async () => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/#angular/cli/bin/postinstall/script.js:5:1)
npm ERR! Linux 3.10.0-957.1.3.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "#angular/cli"
npm ERR! node v6.16.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! #angular/cli#8.0.4 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#8.0.4 postinstall script 'node ./bin/postinstall/script.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the #angular/cli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/postinstall/script.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs #angular/cli
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls #angular/cli
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /app/capman-fe/npm-debug.log
My packages.json is this:
{
"name": "pman-fe",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
... omitted for brevity ...
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.6.8",
"#angular/cli": "^6.0.8",
"#angular/compiler-cli": "^6.0.3",
"#angular/language-service": "^6.0.3",
"#types/d3": "^5.7.1",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.1",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
I was able to solve this error. The problem was that when I installed npm I simply executed: yum -y install npm. I guess the yum repo that the container I have to use doesn't have an up to date copy of the npm rpm. So I changed how I install npm. Now I do this:
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum -y install nodejs
node -v
npm -v
npm install -g #angular/cli
as per https://tecadmin.net/install-latest-nodejs-and-npm-on-centos/
replace
npm install -g #angular/cli
on
npm install -g #angular/cli#~8.0.0
current 8.0.4 version #angular/cli bug with dependency
use ~8.0.0 or less (Ideal for version to match with package.json)
I just encountered the same error on Windows: turns out I had a super old version (v.6.11.0) of Node, so I would just try updating the local version of Node on your centos machine (or whatever environment you are on). Note this will also update your version of npm (most likely).