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

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.

Related

How do I install jest?

Been trying to install jest with this command:
npm i --global jest
and get these messages:
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated request-promise-native#1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
/Users/GRW/.nvm/versions/node/v6.11.1/bin/jest -> /Users/GRW/.nvm/versions/node/v6.11.1/lib/node_modules/jest/bin/jest.js
npm WARN jsdom#16.4.0 requires a peer of canvas#^2.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN ws#7.3.1 requires a peer of bufferutil#^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws#7.3.1 requires a peer of utf-8-validate#^5.0.2 but none is installed. You must install peer dependencies yourself.
+ jest#26.4.2
updated 1 package in 32.731s
Have tried manually installing peer dependencies with:
npm i --save --global canvas#^2.5.0
npm i --save --global bufferutil#^4.0.1
npm i --save --global utf-8-validate#^5.0.2
but still am unable to install jest.
How do I install jest?
EDIT: Forget about the global install and the peer dependency warnings go away, but I still get:
-bash: jest: command not found
Since I seemed to have a prior installation of nvm that kept installations of different versions of node in different directories, I decided to start fresh.
Uninstalled and deleted jest, node, npm, and nvm.
Reinstalled node/npm, and was able to install jest and get the jest -v command to work properly.

npm audit fix --force

I wanted to get rid of my vurnerabilities and used
npm audit fix --force
But i canceled it after a few lines, because it said: "I hope you know what you are doing"
Now if i try
npm install
i get
$ npm install
npm WARN #angular-devkit/build-angular#0.900.7 requires a peer of typescript#>=3.6 < 3.8 but none is installed. You must install peer dependencies yourself.
npm WARN #ngtools/webpack#9.0.7 requires a peer of typescript#>=3.6 < 3.8 but none is installed. You must install peer dependencies yourself.
npm WARN #angular/compiler-cli#9.0.7 requires a peer of typescript#>=3.6 <3.8 but none is installed. You must install peer dependencies yourself.
npm WARN #angular/platform-browser-dynamic#8.1.3 requires a peer of #angular/compiler#8.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN #ngtools/webpack#9.0.7 requires a peer of typescript#>=3.6 < 3.8 but none is installed. You must install peer dependencies yourself.
npm WARN ts-jest#24.0.2 requires a peer of jest#>=24 <25 but none is installed. You must install peer dependencies yourself.
audited 1219421 packages in 12.454s
39 packages are looking for funding
run `npm fund` for details
found 23 vulnerabilities (21 low, 2 moderate)
run `npm audit fix` to fix them, or `npm audit` for details
If I install #angular/compiler#8.1.3 i need #angular/compiler#9.0.7 and vise versa
I had the same problem i resolved it by running the command "ng update", this command will provide you with packages need to be updated and the commands to update it.Hope this will help you.

Cannot find module 'webpack-cli/bin/config-yargs', cannot find module 'webpack-cli'

I have tried nearly all solutions however nothing has worked for me. i cloned a repo from a friend and tried to run the client directory. When i try run client, i get the error:
Cannot find module 'webpack-cli/bin/config-yargs'
Cannot find module 'webpack-cli'
Once i cloned the project i did npm install (as it said in the readME) but when i tried to run the client i would run into this problem:
solutions i tried:
npm install -g vue-cli
npm install --save-dev webpack
npm install --save-dev webpack-cli
i tried 'webpack --version' it will tell me i am missing something and if i want to install it. i click yes and i get the following error:
Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
npm WARN ajv-keywords#3.4.1 requires a peer of ajv#^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware#3.4.0 requires a peer of webpack#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server#3.1.11 requires a peer of webpack#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-cli#3.3.11 requires a peer of webpack#4.x.x but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
webpack-cli#3.3.11
updated 1 package and audited 12959 packages in 13.437s
24 packages are looking for funding
run npm fund for details
found 33 vulnerabilities (22 low, 7 moderate, 4 high)
run npm audit fix to fix them, or npm audit for details
Error: Cannot find module 'webpack-cli'
UPDATE:
My colleague updated some of the dependencies by GitHub bot and i pulled the repo. That seemed to do the trick

resolving npm shrinkwrap peer invalid dependencies

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?

#vue-cli peer dependency warn

I created project using vue-cli 3, cd into it, ran npm install and got this error:
npm WARN ajv-keywords#2.1.1 requires a peer of ajv#^5.0.0 but none is installed. You must install peer dependencies yourself.
I ran
npm install ajv
Which finished with success, but I'm still getting same warn on npm install
npm install -g npm-install-peers
try this it will add all the missing peers and remove all the error