1.0.0 • Published 7 years ago

xiejiabing v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

npm install

如果你自己的模块依赖于某个包,并通过 Node.js 的 require 加载,那么你应该选择本地安装,这种方式也是 npm install 命令的默认行为。 命令执行之后将会在当前的目录下创建一个 node_modules 的目录(如果不存在的话),然后将下载的包保存到这个目录下。

package.json

The best way to manage locally installed npm packages is to create a package.json file. two ways to create package.json a.Run a CLI questionnaire. Code: npm init b.created a default package.json. Code: npm init -y This method will generate a default package.json using information extracted from the current directory. 所以如果原本有node_modules那么package.json会增加很多内容

ists the packages that your project depends on.

allows you to specify the versions of a package that your project can use using semantic versioning rules.

makes your build reproducible, and therefore much easier to share with other developers.

Specifying Dependencies

"dependencies": These packages are required by your application in production.

"devDependencies": These packages are only needed for development and testing.

npm update

升级所有的包

npm uninstall

卸载包

global & locally

There are two ways to install npm packages: locally or globally. Choose which kind of installation to use based on how you want to use the package.

global

If you want to use a package as a command line tool, then install it globally. This way, it works no matter which directory is current. This is the choice you would use if you were installing grunt, for example.

locally

If you want to depend on the package from your own module, then install it locally. This is the choice you would use if you are using require statements, for example.