Npm package has too many dependencies - node.js

Im new to this all npm thing and I have a question about dependencies.
I started the React tutorial and I have been asked to run the following command:
npm install -g create-react-app
also, for a side project I also rn this following command in the same directory:
npm install react-chartjs-2 chart.js
And suddenly, my node_modules contains 800+ folders of packages.
So I found this site that tells you how many packages your package depends on and it showed me that I depend on only 100+ packages.
I know the meaning of npm install.
I find it really unexplainedable, I will appreaciate any help from your side.
Thank you very much.

install npm-remote-ls globally and check the dependencies of any package you want
npm install npm-remote-ls -g
checking react dependencies: npm-remote-ls react

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.

node project not load modules

I pulled project from git, and then ran npm install, which didn't make a mistake, and ran npm run dev after installation
remaind me npm install --save ~plugins/utils ~plugins/axios
But these two documents are my own two packaging, certainly does not need install ah, and installed all the dependencies are not.
But all dependencies can be found under node_module, and I don't know what the problem is
enter image description here
They made a change on nuxt since rc3, now you have to import '~/plugins/axios' not '~plugins/axios', do the same with components

Node not finding dependencies from Gruntfile

I've been using the Yeoman fullstack-angular generator, and it was working great about a week ago.
Now, after generating a new app, node is unable to add in the wired-in dependencies in the Gruntfile.js. Basically, I have to install all the dependencies that should be resolved with npm install. After installing about a dozen npm packages, like jit-grunt, jshint, etc, grunt build/serve will finish, but the app doesn't load in the browser.
I'm sure this is a node/npm issue, as the app generator was working about a week ago. I've tried completely uninstalling and reinstalling. Any guesses as to why this is happening?
Although I get the same behavior with different npm versions, right now I'm at:
npm : 3.3.12
node: 4.2.1
grunt-cli: 0.1.13
grunt: 0.4.5
I'm also getting this error message when I'm installing these packages manually, I feel like it might be related:
Ryans-MacBook-Pro:appTest nonzero$ npm install jit-grunt --save-dev
app-test#0.0.0 /Users/nonzero/Programming/appTEST
└── (empty)
npm ERR! code 1
Try to remove local node_modules folder, and then run npm cache clean. Maybe it will help.

npm install fails because package is missing in registry

I have an issue with a project where we are using node and brunch. The issue is current specific to brunch, but could occur for any module would be my guess.
The easiest way to currently reproduce this, is to do the following in a new folder:
npm init
npm install --save-dev brunch
The issue here is that brunch depends on loggy, which in turn depends on ansi-color, which no longer has an entry in the npmregistry:
https://registry.npmjs.org/ansi-color
I think this might be the github project: https://github.com/loopj/commonjs-ansi-color
In any case, I am unable to proceed, and all our builds fail because they are not able to fetch the given dependency.
I could perhaps use npm shrinkwrap in some way, but that depends on the modules already existing in node_modules, which I am currently missing.
So how can I force npm to use ansi-color from a different location, or ignore the dependency?
Not sure about npm 2 but you can fix this with beta npm 3. npm 3 has flat node_modules directory. So sub modules can sit in the top level. Read the Changelog.
The missing modules can be installed directly from their Github repo as a toplevel dependency in your project. If npm finds the module with the same version in node_modules directory, it won't look for it anymore in the registry.
Install npm 3:
npm install -g npm#3-latest
Then install depencies:
//install missing module from other location
npm install https://github.com/loopj/commonjs-ansi-color.git --save-dev
npm install --save-dev brunch
It looks like ansi-color is back on the npm registry ("https://registry.npmjs.org/ansi-color" is back online)

How do you include npm libraries in a node.js app

I'm trying to create a little app with node-ncurses which I installed over npm install ncurses
with this library install i'm trying to run the examples for node-ncurses from the following
https://github.com/mscdex/node-ncurses/tree/master/examples
But I get path errors with the examples for require('ncurses'), what is wrong?
My ncurses library is install into ~/.npm/ which seems correct to me.
You want to be installing them locally into the same folder of your project. If you miss out the -g flag and just run npm install ncurses within your project directory, you should then be able to run require("ncurses") just fine. All NPM modules installed locally goes into a node_modules folder within your project.
A little further hint, if you install with:
npm install ncurses --save
That will add ncurses to your package.json as a dependency, which means any other dev who might check out your project can run npm install in the project's directory and automatically get ncurses installed as it's listed in package.json as a dependency.
Without the -g flag anything you install with NPM with install into a node_modules folder relative to where you ran the command.
My first recommendation would be to make sure that you are in the working directory of your project and then install ncurses again.
Here is an old, but relevant blog post about how it was designed.

Resources