1 ---
2 title: Downloading and installing packages locally
3 redirect_from:
4 - /downloading-and-installing-packages
5 - /getting-started/installing-npm-packages-locally
6 ---
7
8 You can [install][cli-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.
9
10 ## Installing an unscoped package
11
12 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
13
14 ```
15 npm install <package_name>
16 ```
17
18 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.
19
20 <Note>
21
22 **Note:** If there is no `package.json` file in the local directory, the latest version of the package is installed.
23
24 If there is a `package.json` file, npm installs the latest version that satisfies the [semver rule](about-semantic-versioning) declared in `package.json`.
25
26 </Note>
27
28 ## Installing a scoped public package
29
30 [Scoped public packages][scoped-public-pkg] can be downloaded and installed by anyone, as long as the scope name is referenced during installation:
31
32 ```
33 npm install @scope/package-name
34 ```
35
36 ## Installing a private package
37
38 [Private packages][private-pkg] 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:
39
40 ```
41 npm install @scope/private-package-name
42 ```
43
44 ## Testing package installation
45
46 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:
47
48 ```
49 ls node_modules
50 ```
51
52 ## Installed package version
53
54 If there is a `package.json` file in the directory in which `npm install` is run, npm installs the latest version of the package that satisfies the [semantic versioning rule][semver] declared in `package.json`.
55
56 If there is no `package.json` file, the latest version of the package is installed.
57
58 ## Installing a package with dist-tags
59
60 Like `npm publish`, `npm install <package_name>` will use the `latest` tag by default.
61
62 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:
63
64 ```
65 npm install example-package@beta
66 ```
67
68 ## Resources
69
70 <YouTube id="JDSfqFFbNYQ" />
71
72 [scoped-public-pkg]: about-scopes
73 [private-pkg]: about-private-packages
74 [cli-install]: /cli-documentation/install
75 [semver]: about-semantic-versioning