Gulp install globally - node.js

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.

Related

How does multiple install command in a single npm statement work?

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.

installing node but missing all packages in node_modules

On the Mac, after installing node with:
brew install node
The only package that showed up in /usr/local/lib/node_modules is npm. My previous installation of node contained a bunch of packages such "express, apn, http2, ws, etc."
Any ideas?
There was not a package.json either.
When you install node you only get npm, those other packages you mention, were installed using
# probably with sudo
npm install -g {package}
The package.json is created when you run:
npm init
It has nothing to do with node installation.
If you wish to start a new project:
mkdir project
cd project
npm init
npm install {package-name} {other-package}
And now you will have a node_modules folder inside project/ and a package.json with {package-name} & {other-package} as dependencies

npm init automatically create etc directory and `--save-dev` doesn't work

When I use npm init in cmd, npm creates an etc directory and package.json.
Then when I use npm install stylus --save-dev,the module is downloaded in node_modules directory. But I can not find dependency in package.json
and I realize I can use command ls, mkdir in cmd, which is also confusing.
after npm init I cat package.json
This is my initial directory after I use npm init, I get etc\ directory, which should not be in this directory
This is the directory after I use npm install stylus --save-dev
After installing stylus, I cat package.json, but no dependency in this file
I cannot find out what is wrong.
I'm using Windows 10
node-version 8.9.1
npm version 5.5.1
npx installed
You could try:
npm install -D stylus
or
npm install stylus -D
For multiple packages, do this:
npm install pkg1 pkg2 pkg3 -S
or
npm install -S pkg1 pkg2 pkg3
The difference between -S and -D is -S adds the package(s) to dependencies while -D adds to dev-dependencies.
-S and -D are flags, regardless of where you put it, be it before the package names or after the package names, npm will recognise them and act accordingly.
Check out this command
npm install --save-dev stylus
When you write stylus then --save-dev it is identifying --save-dev as package not as command.
For multiple package to install we write
npm install package1 package2 package3
I was also having the same problem. I assume that you would have set "prefix" key for npm local configuration. Running:
npm config delete prefix
may help. Then start your project:
npm init or npm init -y

Install packages locally with npm

I am new with Node and npm, and when I try to install packages locally, all of the dependencies for that specific package gets installed in the main nodule_modules folder.
It looks like this
LOCALLY
And if I install them globally it looks like this
GLOBALLY
I think I should mention the fact that the folder where I try to install locally is on Desktop.
If you need to install specific dependancies for a project you are working on then do it locally:
npm install <packagename>
If you need something that you can run from the commandline such as grunt or phantomjs (etc..) then install it globally:
npm install -g <packagename>

npm install from package.json, the dependancy -v yields command not found

Reinstalled node/npm from scratch and after npm install I can see the node_modules folder with all of the content from package.json. Checking gulp -v gives command not found in the command line on a mac. If I install gulp globally, gulp -v yields the version.
Is there a way of not installing all dependancies globally to use?
Generally gulp is a package which is used to run some task. These task might need to have administrator privileges. So it is better to install it globally using "npm install -g gulp" command. Here -g means "install it globally".
npm install installs the package locally.

Resources