npm install bower using -g vs --save-dev - node.js

I'm new to node and using npm to both do some node, angular and Express tutorials. I have used bower before in a tutorial. I'm pretty sure I have installed it using -g already as when i run the bower -v command I get back 1.3.3 I am to understand that installing it using -g means, Install this globally so that on the next project I don't have to install it again.
1) Is this correct?
2) When I start working with a new project do I have to initialize bower?
3) Is there any reason I should use install bower --save-dev after I have already installed bower (-g)lobally?
4) What exactly does install bower --save-dev do?
I have searched and get nothing on google or stack over flow when I search "--save-dev".
I really want to understand this and if you help me, it will help me understand installing much more than just bower and how to use those installs. Again, I'm new to the command line for this type of development and new to these technologies, but have some basic understanding.

Using the --save and --save-dev flags when installing will add them to the project's package.json. This allows anyone who might develop on or use the project to install the dependencies as needed with a simple npm install command. By contrast, the -g flag is global only to your local machine.

Related

Why and when should I use npx over npm install or npm install -g (globally)

As mentioned, I was wondering how useful it is to use npx. From what I've read, npx executes packages without downloading them, it doesn't seem right, since the packages are found in: ~/.npm/_npx (first time when using npx with a package, it asks if you want do install that package, and after that, when using that package, it doesn't ask anymore:Example with cowsay)
So, if I am right, it is the same as installing that package globally, using npm install -g. So what is the point of using npx when we could install that package globally and the using it?

Yarn & Npm for Jhipster

I somehow have both yarn and npm for JHipster on my Linux Mint laptop. After I do the followings
yarn global remove generator-jhipster
yarn global add generator-jhipster
There isn't a result for
which jhispter
After I run the following commands
npm uninstall -g generator-jhipster
npm install -g generator-jhipster
an old version Jhipster shows up for
which jhispter
I have done an online search on the subject, but unable to resolve this problem after trying some methods mentioned on some posts.
How to get it right?
When confused about your local setup after installing JHipster through many ways (npm, yarn, linking from the sources, ...), I have found a way that works all the time. Recent version of NodeJs come with a useful tool called npx which can download a package from npm and execute it immediately. So the trick is simply to run:
npx generator-jhipster
You can also run a specific version, for example:
npx generator-jhipster#v5.3.4

Why npm install -g #angular/cli?

I know there are lot many question regarding this npm package installing but I couldn't find the exact relevant answer, I have already installed npm and also developed few applications in my VStudio, Every time before developing the new project of angular do we need to install npm again by typing this in cmd "npm install -g #angular/cli?
Once you have installed #angular/cli globally, in the next project you just need run ng new app-name.
This command will create a folder named 'app-name', than will install all dependencies locally - including #angular/cli.
Installing #angular/cli globally allow you to use 'ng' command everywhere. It's required to install locally because to your project, some specific #angular/cli version is required and newer versions maybe brake.
If your #angular/cli global is newer than the local project version, 'ng' will use the local #angular/cli instead, when you run 'ng serve', for example.
Resume: after installed using npm install -g #angular/cli, you will need just to run ng new app-name.
No. You only need to run
npm i -g #angular/cli
Once ever (or when you update in the future)
And that's used to generate angular apps and different angular cli-related terminal commands. You don't need to run it ever again after that. But you will need to install it locally in your project so that certain things will work propertly

npm peerDependencies React : can't install any packages

I'm building new React App to learn and play with Draft-js, RichStyle Text Editor.
I used create-react-app to initialize my React application. It's working, and very easy to use.
Now, I tried to add semantic-ui-react, which is React version of SemanticUI lib.
Aaaaannd fail.
npm install semantic-ui-react --save
As you can see, same effect for draft-js.
My issue is that normally there's no problem to use draft-js & semantic-ui-react with React 15.4.2. I use this stack in professional env.
Is there something I'm missing with npm ? Is create-react-app can stop this install ?
Now, I can't install any packages. This error shows up everytime. But, I cant still npm start for my local web server. I also tried npm cache clean
Is my very simple package.json
Thanks again for you help.
Solution : Just update NPM and everything working.
Edit : My App folder :
And my npm & node version
My guess is that you have old npm or node versions, you can't start the project with this versions... you can upgrade npm and node programs.
if you are using brew on OSX then you can use following commands to upgrade them.
brew update
brew upgrade node
npm install -g npm

Fresh install of npm and node

I have recently started working with Angular 2 and am unable to get the Angular 2 Quickstart project to run correctly due to a number of errors in my npm dependencies.
Am I able to globally uninstall everything that was previously installed with npm to allow me to do a clean install of it and any required dependencies?
Note: The errors are the same as these examples which are caused by packages needing to be installed globally, however, the errors still occur having followed these steps...
To check your global installed packages you can type:
npm ls -g --depth=0
That lists all global installed packages with depth=0. That mean that it doesn't output dependencies of the packages. You can uninstall global packages with:
npm uninstall -g package-name
Please do not uninstall the npm package itself... But you can update your npm version with npm:
npm install npm -g
As mentioned in the Article your Node.js version should be at least v4.x.x and the npm version should be v3.x.x. You can get the installed versions with these commands:
node -v
npm -v
Updating your Node.js depends on your Operating System. Assuming that you use Windows you should uninstall the current version via control panel and download an actual release from the official Node.js page. https://nodejs.org/en/download/current/
To get a great overview how npm works you should consider reading their
documentation: https://docs.npmjs.com/
Make sure you have the correct node.js version. The guide says 5.0 or greater but points you to the wrong download link.
Try this: https://nodejs.org/en/download/current/
With this node you should be able to follow the guide step by step.

Resources