resolving npm shrinkwrap peer invalid dependencies - npm

I've inherited a react/node/prismic application that uses shrinkwrap, and we need to update the prismic-reactjs package. That package requires higher versions of react and webpack, so I updated those in package.json too, and based on some npm dependency reading I've been roughly following these steps:
rm -fr node_modules
npm uninstall [package_name]
npm prune
npm cache clean
npm install [package_name]
npm shrinkwrap (to check missing dependencies)
npm install
npm shrinkwrap
That last shrinkwrap step shows the remaining "npm ERR! peer invalid:" statements, so I've been working my way top to the bottom of the list, and I'm now down to only three of them:
npm ERR! peer invalid: webpack#^3.1.0, required by extract-text-webpack-plugin#3.0.2
npm ERR! peer invalid: react#^15.6.1, required by react-dom#15.6.1
npm ERR! peer invalid: react#^15, required by react-router-dom#4.1.2
Uh oh- it looks like those peer dependencies need the older versions I'd had for webpack (I updated 3.12.0 -> 4.0.0) and react (I updated 15.6.1 -> 16.0.0).
Of those 3 other packages, one is deprecated so I can't upgrade it if I tried. I could try updating the other 2, but I'm not sure if this is yak shaving- is there a better way forward? Is it possible to have both/conflicting packages in use?

Related

I cannot npm install with just created vue2 + vuetify proj

installed latest vue/cli and created project using vue2.
After this, I added vuetify and thats all for additional to basic vue2 template list of packages.
When I have tryed to use 'npm install'
Found: #vue/cli-service#undefined
npm ERR! node_modules/#vue/cli-service
npm ERR! dev #vue/cli-service#"5.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #vue/cli-service#"^3.0.0 || ^4.0.0 || ^5.0.0-0" from #vue/cli-plugin-babel#5.0.0
npm ERR! node_modules/#vue/cli-plugin-babel
npm ERR! dev #vue/cli-plugin-babel#"5.0.0" from the root project`
can you guys explain me meaning of error
myVersions
As you are seemingly on an old version of npm (<=6.x) you need to install the peer dependency yourself:
npm i -D #vue/cli-service#5.0.0
After installing the dependency, edit your package.json and insert this block on the top level, right after the "devDependencies" object:
"peerDependencies": {
"#vue/cli-service": "^5.0.0"
}
and remove that dependency from the "devDependencies" object.
If you don't want to deal with peer dependencies yourself, upgrade your node and npm version. To upgrade npm only:
npm i -g npm
Despite the fact that I reconfigured entire project. I will anyway answer this question.
Issue was related to cli-service 5.0.0, when I should have had 5.0.8 in order to use babel 5.0.0.
I want to add that if you use default vue.2 template with vue/cli 5.0.8,
You will get another error after installing vuetify, which was not able to fix.
Error is related to vuetify loader.
I fixed it with start up new project and manually inserting all dependencies compatible with vuetify-loader 1.5
Because 1.7 brakes npm run serve

Modifying an npm package locally to manually fix dependency tree issues?

In the process of learning nest.js, I've run into an npm dependency tree issue.
I'm attempting to do something like npm install --save-dev #types/bcrypt #types/passport #types/passport-jwt. This (and similar npm commands) will throw this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #nestjs/passport#8.2.1
npm ERR! Found: passport#0.6.0
npm ERR! node_modules/passport
npm ERR! passport#"^0.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer passport#"^0.4.0 || ^0.5.0" from #nestjs/passport#8.2.1
npm ERR! node_modules/#nestjs/passport
npm ERR! #nestjs/passport#"^8.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: passport#0.5.3
npm ERR! node_modules/passport
npm ERR! peer passport#"^0.4.0 || ^0.5.0" from #nestjs/passport#8.2.1
npm ERR! node_modules/#nestjs/passport
npm ERR! #nestjs/passport#"^8.2.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.
I've traced the problem to the following:
I currently have version 8.2.1 of #nestjs/passport installed - this was released on Feb 16
I can see in my local folder of node_modules/#nestjs/passport/package.json that it has the dependency "passport": "^0.4.0 || ^0.5.0 , as the terminal error implies
In the current Github version of #nestjs/passport, however, I see that they've updated that line to include || ^0.6.0 in late May link
#nestjs/passport hasn't created a new release with this (and other) updates yet though.
Two things I'm wondering:
How can I resolve this dependency issue now, before the maintainers of #nestjs/passport publish their next release?
Why doesn't it work for me to go into my local node_modules/#nestjs/passport/package.json file and manually change it to include ^0.6.0? (After doing that, saving the file, and trying the npm commands again, I still get the same dependency errors)
NPM has already answered the question for you, there are two solution you can try, either run :
npm install --legacy-peer-deps
This section from the npm blog explains what that command does:
We have identified automatic peerDependencies installation as a potentially disruptive change for many users (albeit one that we are confident is the correct behavior for a package manager), we have some tools to minimize this disruption, based on the feedback we get.
We are confident that resolving package trees such that peerDependencies are properly accounted for is the right thing to do. After all, an error here can result in a production issue that’s very difficult to debug later, especially if it occurs deep in a node_modules tree. However, years of not resolving peerDependencies has allowed many projects to fail to notice these problems.
In order to get unblocked and install your project in spite of peerDependencies conflicts, you can use the --legacy-peer-deps flag at install time. It may be that the disruption is too great to take all at once, and we have to have this flag enabled by default for a while as projects gradually update their conflicting dependencies. Our intent is to let the beta give us some more data points to help make that decision carefully.
Or force passport into installing (I'm not sure that is recommended)
npm install [package] --force
This will force npm to fetch remote resources even if a local copy exists on disk.
Good Luck.

How to handle conflicting peer dependencies?

As a devDependency I have installed "#typescript-eslint/parser": "~4.31.2"
Running npm install tells me, that a package needs 4.20.0 and another one 4.28.3 - if I understand the error correctly.
How do I handle these npm package conflicts?
npm ERR! While resolving: #nrwl/eslint-plugin-nx#12.9.0
npm ERR! Found: #typescript-eslint/parser#4.31.2
npm ERR! node_modules/#typescript-eslint/parser
npm ERR! dev #typescript-eslint/parser#"~4.31.2" from the root project
npm ERR! #typescript-eslint/parser#"^4.20.0" from eslint-config-next#11.1.2
npm ERR! node_modules/eslint-config-next
npm ERR! dev eslint-config-next#"11.1.2" from the root project
npm ERR! eslint-config-next#"^11.1.0" from #nrwl/next#12.9.0
npm ERR! node_modules/#nrwl/next
npm ERR! dev #nrwl/next#"12.9.0" from the root project
npm ERR! 1 more (#typescript-eslint/eslint-plugin)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #typescript-eslint/parser#"~4.28.3" from #nrwl/eslint-plugin-nx#12.9.0
npm ERR! node_modules/#nrwl/eslint-plugin-nx
npm ERR! dev #nrwl/eslint-plugin-nx#"12.9.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #typescript-eslint/parser#4.28.5
npm ERR! node_modules/#typescript-eslint/parser
npm ERR! peer #typescript-eslint/parser#"~4.28.3" from #nrwl/eslint-plugin-nx#12.9.0
npm ERR! node_modules/#nrwl/eslint-plugin-nx
npm ERR! dev #nrwl/eslint-plugin-nx#"12.9.0" from the root project
You are using npm 7.x, which is more strict about peer dependencies than npm 6.x. The easiest solution is to run npm install with the --legacy-peer-deps flag. In theory, that may result in some incompatibility issues with peer dependencies. In practice, a lot of people do it anyway. And a lot of people are running npm 6.x and that is the default behavior there, so a lot of people are doing it perhaps without even realizing it.
In your case, #nrwl/eslint-plugin-nx#12.9.0 says that it requires #typescript-eslint/parser#4.28.x and you are installing #typescript-eslint/parser#4.31.2. So if you don't want to use npm 6.x or the --legacy-peer-deps solution, another possibility is to install #typescript-eslint/parser#4.28.5 instead of 4.31.2.
Another thing you can do is open a pull request to update #nrwl/eslint-plugin-nx to use ^ in the relevant peerDependencies entry instead of ~. That will allow 4.x for the peer dependency, rather than limiting it to 4.28.x. It's possible they limited it so severely on purpose, but probably not. (I went to look, but there are hundreds of issues opened in that repository so I didn't spend time looking through them.)
Encountered similar errors when running an Azure DevOps build pipeline (which hadn't changed) against source code that also hadn't changed.
Adding the -g npm-reinstall option to the npm install step resolved the issue.
npm install -g npm-reinstall
While using nx monorepo the solution was to run nx migrate 'package'
e.g.
nx migrate #typescript-eslint/parser

NPM install only creating a package-lock.json?

I am working on a Microsoft Surface 3 running Windows 10. I use git bash for windows for file system management. I'm running npm version 6.14.4 and node version 12.16.2
I'm currently working on an app for some school work and want to run a lite-server instead of vscode's go live extension.
My understanding is that npm install should be run outside of the application as a best practice, but once it's running, you can go back in your terminal in vscode and use npm run start or npm run dev to get the server up. I learned that the two-step process from an online course where I cloned the instructor's work from his Github. In other words, he may have done some preliminary steps that I'm leaving out unintentionally.
I visited the npm docs and spend about an hour familiarizing myself with the technology. Found a nice, simple set of commands to get moving:
$ npm install lite-server --save-dev
(which I run in the project's root folder from git bash)
$ yarn add lite-server --dev # or yarn
...and add a "script" entry within your project's package.json file:
Inside package.json...
"scripts": {
"dev": "lite-server"
},
With the above script entry, you can then start lite-server via:
$ npm run dev
Problem is, I get loads of errors upon NPM install, no package.json file is generated (only a package-lock.json), and attempting npm run dev brings up multiple errors.
From NPM install, I see the following issues mostly:
I get deprecated warnings, chokidar, fsevents, urix, etc.
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.12: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
I am always getting this package-lock.json notice, not sure what it is:
npm notice created a lockfile as package-lock.json. You should commit this file.
Obviously loads of "skipping optional dependency" warnings:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.7 (node_modules\chokidar\node_modules\fsevents):
I get "no such file or directory" warnings:
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\smansfield\desktop\bootcamp_code_responses\class_content_1\activity_4\package.json'
I get these warnings:
npm WARN activity_4 No description
npm WARN activity_4 No repository field.
npm WARN activity_4 No README data
npm WARN activity_4 No license field.
From npm run dev I'm getting these errors:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\smansfield\Desktop\bootcamp_code_responses\class_content_1\activity_4\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\smansfield\Desktop\bootcamp_code_responses\class_content_1\activity_4\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\smansfield\AppData\Roaming\npm-cache_logs\2020-04-26T17_59_00_317Z-debug.log
I've searched all manner of blogs for any insight on these items... No one seems to have posted about these exact items:
why NPM install is responding with so many errors, deprecation, etc.
why am I only getting package-lock.json upon install?
why am I always getting these errors when I try to spin up the lite-server, especially these ENOENT codes and path errors?
Thank you for any insight you can provide me on this. I'll most certainly pay it forward.
Sam
Try run npm init first. It will initialize your project with npm.

Install npm package globally that has peer dependency (not mentioned in package.json)

I am trying to install marktext globally using npm (after cloning the repository):
npm install -g
npm WARN dagre-d3-renderer#0.5.8 requires a peer of d3#^4.13.0 but none is installed. You must install peer dependencies yourself.
How should I install, the peer dependency for the global package? Please give the command so that it is safe and prevents future conflicts.
I did npm install -g d3#^4.13.0 but I still get the same error.
Is this a good idea to install the dependency globally? Also, do I need to lock this at the version globally to prevent auto update when I do global update?
Try it with upgrading npm to version 7
npm install -g npm#7
npm 7 comes with new features. One of them is the automatically installing peer dependencies.
Automatically installing peer dependencies: prior to npm 7 developers needed to manage and install their own peer dependencies. The new peer dependency algorithm ensures that a validly matching peer dependency is found at or above the peer-dependent’s location in the node_modules tree.