How does multiple install command in a single npm statement work? - node.js

Hy
Can someone explain how to read this line npm install -g gulp bower && npm install && bower install
AFAIU, I know first part of the above installs both gulp and bower npm install -g gulp bower however I'm not sure abt the rest of that statement && npm install && bower install
thanks

npm install -g gulp bower this line will install gulp and bower globally.
npm install will install all the packages locally that are defined in package.json. Refer
bower install will install the packages locally that are defined in bower.json. Refer
The && is used to concat each of the commands to run one after another

The && just chains the commands one after the other. So it is like you have
npm install -g gulp bower
npm install
bower install
npm install will install dependencies listed in package.json.
bower install will install dependencies listed in bower.json.

Related

How to install gatsby?

When I try to install gatsby running npm install gatsby-cli -g , it shows that is successfuly installed but it does not work when I run gatsby --help oder gatsby -- build .... , it shows:
-bash: gatsby: command not found
the reason you are getting that is that you haven't installed it globally
$ npm i -g gatsby
$ source ~/.bashrc
source will refresh your terminal so you don't need to close it and open it up again
cli commands only work with globally installed packages
The Gatsby CLI is available via npm and should be installed globally by running:
npm install -g gatsby-cli
If you are unable to successfully run the Gatsby CLI due to a permissions issue, you may want to check out the npm docs on fixing permissions.
global flag -g comes first while installing any package
instead of npm install gatsby-cli -g run npm i -g gatsby-cli
any of below will work
npm install --global <package_name_to_install>
npm install -g <package_name_to_install>
npm i --global <package_name_to_install>
npm i -g <package_name_to_install>
for you package_name_to_install is gatsby-cli

Gulp install globally

I need install gulp. I used this command: npm install gulp gulp-plumber gulp-sass gulp-autoprefixer gulp-concat gulp-uglify gulp-notify
Unfortunelly in my project It was created node_modules directory. How do I do this? I don't have to add files in any project. I would like to use only command "gulp watch".
add -g for global installing
$ npm install -g gulp
OR
$ sudo npm install -g gulp
To install a npm package globally on a machine, use one of
npm i -g <packages>
npm install --global <packages>
However, this doesn't let anybody else know about this dependency. Consider instead adding node_modules/ to your .gitignore file (or the ignore of whatever VCS you are using), then install with
npm i --save-dev <packages>
The --save-dev here means that it knows that this dependency is only for development and not required in deployment. So if you use a script to deploy which installs the npm dependencies, you can have it ignore these packages
Add gulp in your package.json and run npm intall from your project directory.

With NodeJS, How To execute a series of node installs

I've got a file (like below) that has a list of npm install commands. I was hoping I could do
npm < files.txt
to get it to run those but that does not work. How can I install all these packages? I hate to put them all on one big line.
npm install angular angular-ui-router --save
npm install angular watchify browser-sync --save
npm install angular-mocks --save
npm install angular-sanitize --save
....

Why does grunt not get installed via bower.js?

I am new to front end package managers.To install bower, we need npm in prerequisite and then bower takes charge of all the libraries on the client end. However to install grunt, I still need to install it via npm -
npm install -g grunt-cli npm
install grunt-contrib --save-dev
npm install -g grunt
I did not understand why can not we install it via bower as in:
bower install -g grunt-cli
bower install grunt-contrib --save-dev
bower install -g grunt
and manage the bower.json file insted of managing two different - bower.json and package.json?
Bower itself server side dependency which is made using node and you pull it using npm and manage client side dependency by bower
Bower is a package management system for client-side programming unlike npm (node package manager ) which is for server side dependencies
npm runs through the command line and manages dependencies for an application server side as you know nodejs is not client side
so you bower for stuff like ... jquery , angular
and npm for like ... gulp, grunt

Automating "npm install && bower install --dev" with generator-angular for Yeoman

I am trying to figure out how to automate npm install && bower install --dev at the end of the generation of the angular scaffold from the angular generator for Yeoman, and have not found any information that quite matches my problem.
Could someone point me in the right direction?
Run this and it will install npm and bower deps right after finishing scaffolding:
yo angular && npm install && bower install --dev
You could also create a shell alias in your .bashrc,.bashprofile,.zshrc file:
alias ya='yo angular && npm install && bower install --dev'
Then just restart your Terminal and type ya.

Resources