Skip to content

Commit e53b1ca

Browse files
Added a section about global npm install
Closes #505
1 parent dfe2085 commit e53b1ca

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/BestPractices.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Table of Contents
44

55
- [Environment Variables](#environment-variables)
6+
- [Global npm dependencies](#global-npm-dependencies)
67
- [Handling Kernel Signals](#handling-kernel-signals)
78
- [Non-root User](#non-root-user)
89
- [Memory](#memory)
@@ -17,6 +18,15 @@ Run with `NODE_ENV` set to `production`. This is the way you would pass in secre
1718
```
1819
-e "NODE_ENV=production"
1920
```
21+
22+
## Global npm dependencies
23+
24+
If you need to install global npm dependencies, it is recommended to place those dependencies in the [non-root user](#non-root-user) directory. To achieve this, add the following line to you `Dockerfile`
25+
26+
```
27+
NPM_CONFIG_PREFIX=/home/node/.npm-global
28+
```
29+
2030
## Handling Kernel Signals
2131

2232
Node.js was not designed to run as PID 1 which leads to unexpected behaviour when running inside of Docker. For example, a Node.js process running as PID 1 will not respond to `SIGTERM` (`CTRL-C`) and similar signals. As of Docker 1.13, you can use the `--init` flag to wrap your Node.js process with a [lightweight init system](https://github.com/krallin/tini) that properly handles running as PID 1.

0 commit comments

Comments
 (0)