how can i update npm package dependencies - node.js

I have installed an npm package react-native-cool-speedometer and it has it own dependency react-native-svg I am also using react-native-svg in my project but there is an dependency conflict. react-native-cool-speedometer is using react-native-svg#12.1.0 and I am using react-native-svg#13.8.0. this package version has some issue and I want to update it dependency to latest package version 13.8.0.
what I have try. I have tried to downgrade react-native-svg#12.1.0 but its not worked because it has issue.
Invariant Violation: Tried to register two views with the same name RNSVGSvgView, js engine: hermes
I navigate to react-native-speedo-meter directory and tried to update the package with npm update react-native-svg but this has installed all other npm dependencies and but project could not be loaded. it stuck on white screen.
I have also checked this question but it does not help.

Related

Is there a way to save an NPM package that is no longer on NPM?

I am using a package that used to be available on NPM but since then it has been removed from NPM and GitHub.
I still have the package downloaded in my node_modules folder.
Is there a way to save that package and keep it in my node_modules? I am okay with maintaining the package myself.
It would also be great if I could sync just this specific package with Git so I can share it with my teammates.
You can use that package as a local module and install it as a package in your application.
Check this out: Local dependency in package.json

npm and node versions incompatible can produce error

I've installed nodenv to manage versions of node and npm in my pc. Because when I try install packages like , angular-cli, webpack , typescript, angular2 and another, I get errors
FIRST QUESTION: Can an version node or npm produce error when i install a package?
Some packages tells things like: "The generated project has dependencies that require Node 4.x.x and NPM 3.x.x."
but they don't mention the exact version. by example Can a version of node 4.1.5 produce errors and not the version 4.0.5 ?
SECOND QUESTION:
I don't like these packages need be installed like global (-g) and the problems i see sometimes there are conflicts between global packages installed.
Example error:
npm WARN EPEERINVALID string-replace-loader#1.0.3 requires a peer of webpack#1.x.x || 2.x.x but none was installed.
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-macosx.zip
but what about if two global packages use same global package, but some of they use a different version for every package?
Its up to npm package owners to define in their package.json all the upstream dependencies with a set of working versions which play well together ... challenge is as a package owner to make your package.json loose as possible regarding upstream dependencies to enable pulling in newer releases of these dependent packages yet tight enough that your published package still works
Often this is not the case which can lead to version mismatch invoked errors ... if possible always use most recent package releases this goes for nodejs itself as well
When package.json mentions versions such as 3.x.x it means it should work with any value of x.x so just chose the highest number to fit the pattern
Where possible avoid doing a global install unless it is for command line executables ... this is especially true for packages which your code pulls in as opposed to an executable centric package
UPDATE I am now able to successfully install this
npm install -g angular-cli
using the latest release of node
node --version
v6.5.0
so I suggest you upgrade your own project code and node version to avoid that pinned release which fails and work with the most current releases

npm install on cleaned project does not 'update'

I have the following scenario:
project with installed node_modules
work directory is emptied
project is freshly cloned from git
npm install is run
I have a dependency required as ~1.0.0 in package.json. This dependency was previously installed in version 1.0.1. It has now newer versions, e.g. 1.0.2, available but still gets installed as 1.0.1 by npm install. But I want the dependency to get updated within the range that I specified.
Why is that and how could I solve this? Would using npm update instead/ afterwards help?
BR
Chris

I don't know why the core modules in node js are not being recognized within my project using IntelliJ Idea (2016)

I keep getting the error: Cannot find module 'serve-favicon.' This error occurs not just for serve-favicon but for all core modules which also includes 'body-parser', 'cookie-parser', etc. I am using IntelliJ IDEA (version: 2016). I already enabled the Node.js Core library, and I have been able to use core modules in other projects successfully. What is different about this project however, is that I pulled it from github. Do I need to install another plugin? If yes, which one? Do I need to add another package?
serve-favicon, body-parser, cookie-parser are not node.js core modules.
You will need to install these dependencies from npm registry. To install these dependencies, you will need to run
npm install <package-name> --save
If you have pulled the project from github, chances are there will be a package.json file with a list of dependencies. In that case, all you need to do is run npm install from the project folder.

NPM - Sub-dependencies are in another location after upgraded to Node v.5.0.0 - Why?

I have a problem with npm install {moduleName}
previously, all my sub-dependencies were installed under {projectName}/node_modules/{moduleName}/node_modules/
After I upgraded to Node v5.0.0 (via installer on website), all my sub-dependencies are installed together with the dependencies under {projectName}/node_modules/
Why is that happening? And how can I change it back to the previous behavior?
Node v5.x comes with npm 3.x. This is the intended behavior in npm 3.x. You can read more about it in the npm 3.0.0 release notes, but here's the gist:
Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.
I'm not sure why you'd want the old behavior—it was a dependency nightmare, hence the change—but if you really want to you can downgrade to npm 2.x:
$ npm install -g npm#latest-2

Resources