<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                **npm:node package manager** npm is the world’s largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well. [[npm官方文檔]](https://docs.npmjs.com/about-npm/) 什么是npm、cnpm、bower? 簡單地說,就是幫你下載好你需要的css或者js庫,而且三者功能也都是一樣的。那為什么要下載這3個不同的呢?據說npm容易被墻……而cnpm是淘寶的鏡像,所以通常用cnpm代替npm。至于bower,是因為bower更多地用于前端開發。但是因為它也是依賴于npm的,所以沒有npm,就沒法載bower……不知道說了那么多你懂了沒,但是這不重要~你所需要做的就是分別安裝這3個,然后將bower為己所用。 [TOC] ## About NPM npm consists of three distinct components: * the website * the Command Line Interface (CLI) * the registry Use the [*website*](https://npmjs.com/) to discover packages, set up profiles, and manage other aspects of your npm experience. For example, you can set up [Orgs](https://www.npmjs.com/features)(organizations) to manage access to public or private packages. The [*CLI*](https://docs.npmjs.com/cli/npm) runs from a terminal, and is how most developers interact with npm. The [*registry*](https://docs.npmjs.com/misc/registry) is a large public database of JavaScript software and the meta-information surrounding it. **Use npm to . . .** * Adapt packages of code for your apps, or incorporate packages as they are. * Download standalone tools you can use right away. * Run packages without downloading using[npx](https://www.npmjs.com/package/npx). * Share code with any npm user, anywhere. * Restrict code to specific developers. * Create Orgs (organizations) to coordinate package maintenance, coding, and developers. * Form virtual teams by using Orgs. * Manage multiple versions of code and code dependencies. * Update applications easily when underlying code is updated. * Discover multiple ways to solve the same puzzle. * Find other developers who are working on similar problems and projects. ## Configuring your local environment [[官方網站]](https://docs.npmjs.com/getting-started/configuring-your-local-environment) ## Packages and modules [[官方網站]](https://docs.npmjs.com/about-packages-and-modules) The npm registry contains packages, many of which are also Node modules, or contain Node modules. ### Package A **package** is a file or directory that is described by a`package.json`file. A package must contain a`package.json`file in order to be published to the npm registry. A package is any of the following: * a) A folder containing a program described by a`package.json`file. * b) A gzipped tarball containing (a). * c) A URL that resolves to (b). * d) A `<name>@<version>` that is published on the registry with (c). * e) A `<name>@<tag>` that points to (d). * f) A `<name>` that has a `latest` tag satisfying (e). * g) A `git` url that, when cloned, results in (a). Git URLs used for npm packages can be formatted in the following ways: * `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` The `commit-ish` can be any tag, sha, or branch that can be supplied as an argument to `git checkout`. The default `commit-ish` is `master`. ### Module A **module** is any file or directory in the`node_modules`directory that can be loaded by the Node.js`require()`function. To be loaded by the Node.js`require()`function, a module must be one of the following: * A folder with a `package.json` file containing a `"main"` field. * A folder with an `index.js` file in it. * A JavaScript file. >[warning] Note:Since modules are not required to have a `package.json` file, not all modules are packages. Only modules that have a `package.json` file are also packages. In the context of a Node program, the `module` is also the thing that was loaded *from* a file. For example, in the following program: ~~~ var req = require('request') ~~~ ## npm package scope, access level, and visibility [[官方網站]](https://docs.npmjs.com/package-scope-access-level-and-visibility) Visibility of npm packages depends on the scope (namespace) in which the package is contained, and the access level (private or public) set for the package. >[warning] Note:To create Org-scoped packages, you must first create an Org. ### Public registry | Scope | Access level | Can view and download | Can write (publish) | | --- | --- | --- | --- | | Org | Private | Members of a team in the Org with read access to the package | Members of a team in the Org with read and write access to the package | | Org | Public | Everyone | Members of a team in the Org with read and write access to the package | | User | Private | The package owner and users who have been granted read access to the package | The package owner and users who have been granted read and write access to the package | | User | Public | Everyone | The package owner and users who have been granted read and write access to the package | | Unscoped | Public | Everyone | The package owner and users who have been granted read and write access to the package | >[warning] Note:Only user accounts can create and manage unscoped packages. Orgs can only manage scoped packages. ### npm Enterprise The following table applies to customers who purchased [npm Enterprise](https://docs.npmjs.com/enterprise) after July 26, 2018. | Scope | Access level | Can view and download | Can write (publish) | | --- | --- | --- | --- | | Org | Private | Logged-in members of the Enterprise registry who belong to a team in the Org with read access to the package | Logged-in members of the Enterprise registry who belong to a team in the Org with read and write access to the package | | Org | Public | All logged-in members of the Enterprise registry | Logged-in members of the Enterprise registry who belong to a team in the Org with read and write access to the package | | User | Private | The package owner and logged-in members of the Enterprise registry who have been granted read access to the package | The package owner and logged-in members of the Enterprise registry who have been granted read and write access to the package | | User | Public | All logged-in members of the Enterprise registry | The package owner and logged-in members of the Enterprise registry who have been granted read and write access to the package | | Unscoped | Public | All users of the Enterprise registry | None (see note below) | >[warning] Note:The unscoped namespace on npm Enterprise is reserved for unscoped packages in the public npm registry. To prevent npm Enterprise users from accidentally publishing proprietary code to the public npm registry, where it would be visible to anyone on the internet, we do not allow publishing unscoped packages to npm Enterprise. ## Getting packages from the registry [[官方網站]](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry) ### Searching for and choosing packages to download You can use the npm search bar to find packages to use in your projects. npm search uses npms and the npms analyzer; for more information on both, see https://npms.io/about. ### Downloading and installing packages locally You can `install` a package locally if you want to depend on the package from your own module, using something like Node.js `require`. This is `npm install`’s default behavior. **Installing an unscoped package** Unscoped packages are always public, which means they can be searched for, downloaded, and installed by anyone. To install a public package, on the command line, run ~~~ npm install <package_name> ~~~ This will create the`node_modules`directory in your current directory (if one doesn’t exist yet) and will download the package to that directory. >[warning] Note:If there is no `package.json` file in the local directory, the latest version of the package is installed. If there is a `package.json` file, npm installs the latest version that satisfies the [semver rule](https://docs.npmjs.com/about-semantic-versioning) declared in`package.json`. **Installed a scoped public package** [Scoped public packages](https://docs.npmjs.com/about-scopes) can be downloaded and installed by anyone, as long as the scope name is referenced during installation: ~~~ npm install @scope/package-name ~~~ **Installing a private package** [Private packages](https://docs.npmjs.com/about-private-packages)can only be downloaded and installed by those who have been granted read access to the package. Since private packages are always scoped, you must reference the scope name during installation: ~~~ npm install @scope/private-package-name ~~~ **Testing package installation** To confirm that `npm install` worked correctly, in your module directory, check that a `node_modules` directory exists and that it contains a directory for the package(s) you installed: ~~~ ls node_modules | grep lodash lodash@ ~~~ **Installed package version** If there is a `package.json` file in the directory in which `npm install` is run, npm instalsx the latest version of the package that satisfies the [semantic versioning rule](https://docs.npmjs.com/about-semantic-versioning) declared in `package.json`. If there is no `package.json` file, the latest version of the package is installed. **Installing a package with dist-tags** Like `npm publish`, `npm install <package_name>` will use the `latest` tag by default. To override this behavior, use`npm install <package_name>@<tag>`. For example, to install the`example-package`at the version tagged with`beta`, you would run the following command: ~~~ npm install example-package@beta ~~~ ### Downloading and installing packages globally Tip:If you are using npm 5.2 or higher, we recommend using `npx` to run packages globally. [Installing](https://docs.npmjs.com/cli/install) a package globally allows you to use the code in the package as a set of tools on your local computer. To download and install packages globally, on the command line, run the following command: ~~~ npm install -g <package_name> ~~~ If you get an EACCES permissions error, you may need to reinstall npm with a version manager or manually change npm’s default directory. For more information, see “[Resolving EACCES permissions errors when installing packages globally](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)”. ## cnpm 使用說明 [[淘寶 NPM 鏡像]](https://npm.taobao.org/) 可以使用淘寶定制的[`cnpm`](https://github.com/cnpm/cnpm)(gzip 壓縮支持) 命令行工具代替默認的`npm`: ~~~bash $ npm install -g cnpm --registry=https://registry.npm.taobao.org ~~~ 或者直接通過添加`npm`參數`alias`一個新命令: ~~~bash alias cnpm="npm --registry=https://registry.npm.taobao.org \ --cache=$HOME/.npm/.cache/cnpm \ --disturl=https://npm.taobao.org/dist \ --userconfig=$HOME/.cnpmrc" # Or alias it in .bashrc or .zshrc $ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \ --cache=$HOME/.npm/.cache/cnpm \ --disturl=https://npm.taobao.org/dist \ --userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc ~~~ ## npm安裝package.json中的模塊依賴 1.package.json不存在時 命令:`npm init`可自動創建package.json文件 2.package.json存在時 直接命令:`npm install` 或者 `npm install –save-dev`會自動將package.json中的模塊安裝到node-modules文件夾下
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看