How to resolve the setup of the Tailwind CSS with Next.js in Visual Studio Code [duplicate] - node.js

I am trying to npm install vue-mapbox mapbox-gl, and I'm getting a dependency tree error.
I'm running Nuxt.js SSR with Vuetify and haven't installed anything related to Mapbox prior to running this install and am getting this error.
38 error code ERESOLVE
39 error ERESOLVE unable to resolve dependency tree
40 error
41 error While resolving: [1mexample[22m#[1m1.0.0[22m
41 error Found: [1mmapbox-gl[22m#[1m1.13.0[22m[2m[22m
41 error [2mnode_modules/mapbox-gl[22m
41 error [1mmapbox-gl[22m#"[1m^1.13.0[22m" from the root project
41 error
41 error Could not resolve dependency:
41 error [35mpeer[39m [1mmapbox-gl[22m#"[1m^0.53.0[22m" from [1mvue-mapbox[22m#[1m0.4.1[22m[2m[22m
41 error [2mnode_modules/vue-mapbox[22m
41 error [1mvue-mapbox[22m#"[1m*[22m" from the root project
41 error
41 error Fix the upstream dependency conflict, or retry
41 error this command with --force, or --legacy-peer-deps
41 error to accept an incorrect (and potentially broken) dependency resolution.
41 error
41 error See /Users/user/.npm/eresolve-report.txt for a full report.
42 verbose exit 1
What's the right way to go about fixing this upstream dependency conflict?

It looks like it's a problem with peer dependencies in the latest version of npm (v7) which is still a beta version.
Try with npm install --legacy-peer-deps. For detailed information check the blog post npm v7 Series - Beta Release! And: SemVer-Major Changes in npm v7.

Use --legacy-peer-deps after npm install. For example, if you want to install Radium, use:
npm install --legacy-peer-deps --save radium

There are two ways:
use npm install --legacy-peer-deps to install, and if this doesn't work use
the force method. Add --force next to npm install: npm install --force

You can follow these commands
First type:
npm config set legacy-peer-deps true
Then type:
npx create-react-app my-app

Your dependency mexample requires mmapbox-gl v1.13.0 and mvue-mapbox requires mmapbox-gl v0.53.0.
NPM doesn't know which version to install, so it gives a warning. You can bypass the errors using -- force or --legacy-peer-deps, but you are ignoring an error, and making unexpected results.
Production Options:
Probably one of your packages is outdated. Upgrading packages and fixing upgrade errors might fix the dependency conflict.
Overriding a dependency manually to avoid the warning and error. You are setting the version to a specific one that you know that works. Usually the newer version.
Example solution with override. Your package.json file will look like this:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"mexample": "^1.2.0",
"vue-mapbox": "*"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"overrides": {
"mmapbox-gl": "1.13.0"
}
}
The last option is bypassing using either:
--legacy-peer-deps completely ignores all peerDependencies using the newest version without pinning on file package-lock.json
--force forces the use of the newest, pinning all the versions on package-lock.json
Extra: You shouldn't use "*" as a version, because it might update major and break dependencies.

Until npm version 7.19.1, it still had the same issue. After upgrading to version 7.20.3, use command npm install -g npm#latest and npm audit fix. All packages will be fixed without error.

I tried multiple ways, but nothing was working for me. At last I tried this and it worked:
npm config set legacy-peer-deps true
Run this in the project folder and then try to install any package. It might work for you as well.

To solve it, fix the upstream dependency conflict installing NPM packages error
Method 1. Just use --legacy-peer-deps after npm install.
For example, if you want to install Axios, use
npm install --legacy-peer-deps --save axios.
Method 2. Updating npm and 'audit fix'
npm I -g npm#latest
npm audit fix --force
Method 3. Using --force to install packages
npm install axios --force

I was stuck on this issue for long which also makes error from other commands which calls for some install commands that was breaking.
The only solution that works (maybe suppresses the error) is
npm config set legacy-peer-deps true
This will set the configuration of legacy-peer-deps to true

To resolve npm dependencies and conflicts with npm packages, use npm-check-updates.

Almost all answers here suggest using force or legacy-peer-deps. Though this will technically work, please note that this is not recommended by NPM if you can avoid it anymore (source). Some folks may not have a choice, but I was able to resolve my dependency conflicts by deleting node-modules and package-lock.json then manually updating packages to their latest version one at a time until it stopped complaining (packages mentioned in the error messages after running npm i. Not a great or clean solution, but at least my packages are up-to-date and I'm not ignoring errors or using legacy solutions.

A lot of upvotes for using --legacy-peer-deps, but if --force works, I would recommend using that since it still pins many dependency versions while --legacy-peer-deps ignores peer dependencies entirely. See the example below:
npm: When to use --force and --legacy-peer-deps
I started getting this error on Azure DevOps a few days ago. I initially thought it was a glitch on the Azure side, but since it continued, we started looking into it a bit more.
It turns out the agent we are using, windows-2022, was updated a few days ago:
Updating readme file for win22 version 20220607.3 (#5713)
Node and NPM now match the latest Node.js LTS version: 16.15.1 (includes npm 8.11.0)
Downloads
You can view all agents-included software on Microsoft-hosted agents, Software.
After reading on Microsoft Visual Studio Developer Community, they recommend downgrading Node.js using Node.js Tool Installer task like this:
- task: NodeTool#0
inputs:
versionSpec: '16.14.2'
Node.js Tool Installer task
npm install fails in Azure DevOps Hosted Agent
However, we decided that we do not want to downgrade Node.js, so the first step was matching Node.js locally with LTS version 16.15.1 and npm 8.11.0.
When running npm ci, we then got the same error locally.
We tried npm ci --force and we then got this error:
npm ci can only install packages when your package.json and
package-lock.json or npm-shrinkwrap.json are in sync. Please update
your lock file with npm install before continuing.
npm install gave the same error even after node_modules was manually removed, but npm install --force worked, and it generated a new package-lock.json file.
npm ci still failed with the same error, but running npm ci --force worked. We decided to update Azure DevOps .yml to include --force and checked in the new package-lock.json file. After doing this, everything worked like before and we could now update our packages one by one.

delete the package-lock.json file
modify the package.json file, updating the version as indicated by the peer dependency
Add a tilde or caret for allowing install latest version and resolving dependency issues, for example :
~1.0.2 means to install version 1.0.2 or the latest patch version such as 1.0.4.
^1.0.2 means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.
run npm install or npm udpate

I resolved this by adding
steps:
- task: NodeTool#0
inputs:
versionSpec: '12.x'

Nothing here worked for me.
After struggling with this issue for so long, I found a solution that worked.
Apparently I had some packages installed globally.
Listed them with:
npm list -g --depth=0
Then removed the unwanted packages with:
npm uninstall -g <package-name>
Finally I got the problem fixed

Related

node modules deleted. now npm is not installing

I deleted the node modules and package.json.lock file in my client side MERN Stack project folder and tried reinstalling the node modules by typing "npm install" command in the terminal. but it's showing me an error. 1. I have tried clearing cache using "npm cache clean --force".
2. I have tried reinstalling npm using "npm install -g npm".
3. I have tried updating the npm using "npm install -g npm#latest".
But nothing works. Please help me resolve this issue. below are my package.json file and the error in my terminal while installing node modules.
i was expecting that node modules will be reinstalled with all the dependencies mentioned in my package.json file.
NPM changed the way of resolving peer dependencies in v7, but this new way does not allow conflicting dependencies in the dependency tree. The simplest way to solve this would be to use the --legacy-peer-deps option to use the old way of resolving dependencies.
The hard(but better) way to solve it would be to spend some time to update the dependencies in a way that there is no conflicting dependency.

npm ci giving Conflicting peer dependency

I am trying to install the dependencies from docker file with command RUN npm ci. But I am getting the following error Conflicting peer dependencies. Fix the upstream dependency conflict, or retry this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.. In my local project I have overcome this issue while running npm install --force. How I can fix this inside the docker while building and running this command RUN npm ci.
As I have understood npm ci will look it either from the package-lock.json or npm-shrinkwrap.json. But still facing this issue. Cannot figure it out what is causing this.
They introduce a breaking changes in npm#8.6 (yes! a minor version bump, with a major breaking changes).
The update changes the behavior of package installation, both from npm install and npm ci.
Previously, the npm ci command would blindly install whatever was in the lock file. AS IS, it will validates both the package-lock.json and package.json is in a consistent state.
You could read more about the issue here: github.com/npm/cli/issues/4998, github.com/npm/cli/issues/5113, and github.com/npm/cli/issues/4664
I also started to get this error on pipe. What is interesting I always have had peer dependency conflict but it was only appearing with npm install. The best option is to run script with flag --legacy-peer-deps it will skip checking peer dependency. Peer dependency should be installed manually in package.json.
npm i --force
solved my problem
Note : I got :
added 482 packages, and audited 483 packages in 3m
Some issues need review, and may require choosing
a different dependency.

npm install NOT dowloading latest package

[context]
I have a problem to use "npm install" command to update my package.json with latest dependencies.
I am running on a Jenkins slave with Multibranch Pipeline, not sure if this is the cause?
There is another post having a similar issue, but not been answered ...
NPM package.json not updating after npm install
Here is my package.json
"dependencies": {
"#company/ai-integration-test": "^1.0.1-NIGHTLY",
"#company/ai-portal": "^1.0.1-NIGHTLY",
"#company/ai-portal-lambdas": "^1.0.1-NIGHTLY"
}
Here is the result for "npm outdated"
[What do I expect]
I would like to get my package.json by running some command if "npm install" is the correct command to use? Thanks a million !!
delete your package-lock.json file.
and try npm install again.
But npm install will only update those packages which have "^" in their version, it means auto-update that particular package when you run npm install.
I found npm update command helps me to update package.json to the latest available version. But not sure if I am doing the right things though ... inputs are still welcome !! TKS !!
[Final Answer]
It turns out the problem was caused by our company's IT firewall settings.
The firewall intermittently forge SSL certificate for security reasons.
When that happens, downloading latest package fails without giving error messages.
some of those updates are the major release npm update won't update to the latest version.
The major release does not update in this way because they maybe introduce breaking changes. npm save you from that trouble
npm install -g npm-check-updates
then run it:
ncu -u
this will update all packages to the latest version in the package.json

how to install only package.json dependencies with their own versions by using npm install or yarn

I work on a new project, but I can't install packages correctly. I used npm install, yarn, npm install --only=dev, but there aren't enough. I also try like that deleting node_modules and package-lock.json. The state was the same.
We use in the project babel's 6.x version. Babel has a update, 7.x, I think I get the error because of version differences when I run npm install, npm install --only=dev, yarn.
npm WARN deprecated babel-preset-es2015#6.24.1: � Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN babel-loader#8.0.4 requires a peer of #babel/core#^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN babel-loader#8.0.4 requires a peer of webpack#>=2 but none is installed. You must install peer dependencies yourself.
I use WebStorm. Before that, I tried to get package for another project with npm install. "Npm" is not successful. WebStorm advice me using Yarn, and I used Yarn. It was worked.
What should I do in the state?
After npm install, when I run parcel index.html, I get the console error
"Uncaught TypeError: window.fooes is not a constructor", Uncaught ReferenceError: regeneratorRuntime is not defined.
I know that the code doesn't have a problem, because project work on the team's computer correctly.
The first and most important:
Never use npm and yarn at the same time. Choose one of them and use that only because they are both using lock files based on the installed packages.
Which one to use:
npm and yarn are both using the NPM software registry database. So in the end the final result when installing packages are the same, but yarn does the job much-much faster. Yarn was developed by Facebook because the slowness of npm. So I prefer yarn, I'm not using npm commands anymore.
To your problem:
Delete the package-lock.json and yarn.lock lock files in your project root directory.
Also delete the whole node_modules directory.
Now you have only your package.json file. Make a backup of this file!
Open the original package.json and I suggest you to first delete all entries from it
related to Babel and save it.
Now run the yarn command (without params) in the project root (where your package.json file is). This should install all your packages again.
Then install the latest packages of Babel using these commands:
yarn add -D #babel/core
yarn add -D #babel/preset-env
yarn add -D babel-loader
You may need other packages from Babel. Have a look on your backed up package.json and search for the latest versions in the npm registry or Babel's plugins documentation page for the remaining plugins (if any).

EINTEGRITY: npm 5.0 integrity check and modernizr.com dependency

I've encountered this error when installing deps of my package:
$ npm i
npm ERR! code EINTEGRITY
npm ERR! sha1-tU7jWojzuU8MIY2VLAx+BwluNo0= integrity checksum failed when using sha1: wanted sha1-tU7jWojzuU8MIY2VLAx+BwluNo0= but got sha1-oXYP0kzpbhku0KU+phy353lbBhQ=. (26624 bytes)
npm ERR! A complete log of this run can be found in:
npm ERR! /home/tlenex/.npm/_logs/2017-06-22T10_18_19_773Z-debug.log
the problem is with my Modernizr dependency:
"dependencies": {
"Modernizr": "https://modernizr.com/download?setclasses-flash"
}
is there any way to solve this or ignore this integrity check?
Currently I have to run
npm i https://modernizr.com/download?setclasses-flash
again to get things working, which overrides the "integrity" field for "Modernizr" in my package-lock.json.
This may happen every time there is a change in Modernizr package fetched from this link and my package dependencies need to be reinstalled (for example, each time on CI build)
If there is no other way of solving this? I hope I wont have to place package-lock.json in my .gitignore file :(
More data about my enviroment:
$ npm -v
5.0.3
$ node -v
v6.11.0
Edit package-lock.json , find the one you want to skip in this case the one that its failing
sha1-tU7jWojzuU8MIY2VLAx+BwluNo0
and remove the integrity parameter from it i.e
},
"range-parser": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
"integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=",
"dev": true
},
to...
},
"range-parser": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
"dev": true
},
after that run npm install, will check the rest, skip this integrity
The point of the integrity field is to alert you when something has changed, so if you do not want it to exist, you can disable package-lock.json files in your npmrc. Just set package-lock=false
Note: I am the developer of Modernizr, and spoke with the npm-cli team about this issue. The root cause appears to be the change of the SHA type between npm5 and earlier versions. Nuking the node_modules folder will fix it
Find all outdated packages and update theme:
npm outdated -g
sudo npm i -g outDatedPKG
Upgrade npm to lateste version with:
sudo npm i -g npm
Delete package-lock.json file.
Delete _cacache directory in ~/.npm:
npm cache verify
4.1. Every time i get that error, do steps 2 & 3.
If you still get the error, clear npm's cache:
npm cache clean --force
I had this same error and I solved it by :
Deleting package-lock.json
Running "npm install"
I finally resolved this issue.
Our team moved away from URL dependency without SEMVER notation, in this case https://modernizr.com/download?setclasses-flash and used modernizr-loader with webpack. There are also equivalents for gulp and grunt tools available on npm, pick and use one you like the most.
After using them, we finally get rid of returning EINTEGRITY npm error without nuking package-lock.json or node_modules.
Just do two things for the solution
first :
npm cache clean --force
second :
npm i -g npm
and than install what u want
$ rm -rf package-lock.json node_modules
$ npm install --cache /tmp/empty-npm-cache
If this fixes it, clear your global npm cache to fix the corruption.

Resources