npm
+7m
developers
2194483013
weekly download
481,191
packages
Yarn
package?
- a folder containing a program described by a package.json file
- a gzipped tarball containing (1)
- a url that resolves to (2)
- a <name>@<version> that is published on the registry with (3)
- a <name>@<tag> that points to (4)
- a <name> that has a latest tag satisfying (5)
- a git url that, when cloned, results in (1).
-
git://github.com/user/project.git#commit-ish
- git+ssh://user@hostname:project.git#commit-ish
- git+http://user@hostname/project/blah.git#commit-ish
- git+https://user@hostname/project/blah.git#commit-ish
Git urls
- -v: --version
- -h, -?, --help, -H: --usage
- -s, --silent: --loglevel silent
- -q, --quiet: --loglevel warn
- -d: --loglevel info
- -dd, --verbose: --loglevel verbose
- -ddd: --loglevel silly
- -g: --global
- -C: --prefix
- -l: --long
- -m: --message
- -p, --porcelain: --parseable
- -reg: --registry
- -f: --force
- -desc: --description
- -S: --save
- -D: --save-dev
- -O: --save-optional
- -B: --save-bundle
- -E: --save-exact
- -y: --yes
- -n: --yes false
- ll and la commands: ls --long
npm shortcuts
package.json
{
"name": "my_package",
"description": "",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/ashleygwilliams/my_package.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/ashleygwilliams/my_package/issues"
},
"homepage": "https://github.com/ashleygwilliams/my_package"
}
> npm init
D:\projects\app>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
name: (app)
> npm init --yes
> npm init -y
Set
> npm set init.author.email "email@epam.com"
> npm set init.author.name "Shukhratbek"
> npm set init.license "MIT"
Get
> npm get init.author.email
Delete
> npm config delete init.author.name
Config
npm help
npm -h
npm help
npm install -h
Terminal Help
HTML Help
npm help install
npm help uninstall
npm help prune
> npm help <command>
Help search command
npm help-search remove
> npm help-search <command>
npm install
> npm install <package_name>
> npm i <package_name>
npm install (with no args, in package dir) npm install [<@scope>/]<name> npm install [<@scope>/]<name>@<tag> npm install [<@scope>/]<name>@<version> npm install [<@scope>/]<name>@<version range> npm install <tarball file> npm install <tarball url> npm install <folder>
-S|--save -D|--save-dev -O|--save-optional -E|--save-exact -B|--save-bundle
npm i <package> [options]
npm install sax --save
npm install githubname/reponame
npm install @myorg/privatepackage
npm install node-tap --save-dev
npm install dtrace-provider --save-optional
npm install readable-stream --save --save-exact
npm install ansi-regex --save --save-bundle
--dry-run
-f|--force
-g|--global
npm i <package> [options]
npm install sax --dry-run
npm install sax -f
npm install sax --force
npm install sax -g
npm install sax --global
npm i gist:<hash>
npm list
> ls node_modules/
> npm list
> npm ls
> npm list --depth 1
> npm list --depth 0
> npm list --global true
> npm list --depth --long true
> npm list --depth --json true
> npm list --depth --dev true
> npm list --depth --prod true
npm uninstall
> npm uninstall lodash
> npm rm lodash
> npm un lodash
> npm r lodash
> npm r lodash -g
> cat package.json
> npm uninstall lodash --save
> cat package.json
npm update
> npm update
> npm update lodash
npm registry
http://registry.npmjs.org/<package>
npm registry
http://npm.im/<package>
npm search
> npm search <package>
npm prune
> npm prune
> npm prune <package>
> npm prune --production
npm repo
> npm repo <package>
upgrade npm
> npm i npm@latest -g
npm scripts
- prepublish: Run BEFORE the package is published. (Also run on local npm installwithout any arguments. See below.)
- prepare: Run both BEFORE the package is published, and on local npm installwithout any arguments. (See below.) This is run AFTER prepublish, but BEFORE prepublishOnly.
- prepublishOnly: Run BEFORE the package is published. (See below.)
- publish, postpublish: Run AFTER the package is published.
- preinstall: Run BEFORE the package is installed
- install, postinstall: Run AFTER the package is installed.
- preuninstall, uninstall: Run BEFORE the package is uninstalled.
- postuninstall: Run AFTER the package is uninstalled.
- preversion: Run BEFORE bumping the package version.
- version: Run AFTER bumping the package version, but BEFORE commit.
- postversion: Run AFTER bumping the package version, and AFTER commit.
- pretest, test, posttest: Run by the npm test command.
- prestop, stop, poststop: Run by the npm stop command.
- prestart, start, poststart: Run by the npm start command.
- prerestart, restart, postrestart: Run by the npm restart command. Note: npm restart will run the stop and start scripts if no restart script is provided.
- preshrinkwrap, shrinkwrap, postshrinkwrap: Run by the npm shrinkwrapcommand.
npm run <script>
npm user
> npm adduser
Username: shuhratbek
Password:
Email: shuhratbek.26@gmail.com
Prepare package for publish
- Create git repository
- Create package.json
> npm publish
npm publish update
npm release beta
npm
By Shuhratbek Mamadaliyev
npm
- 1,138