aboutsummaryrefslogtreecommitdiff
path: root/src/node/README.md
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2022-11-03 03:02:26 +0300
committerGitHub <noreply@github.com>2022-11-03 03:02:26 +0300
commit73a9c7d38293067a4081b8d79dd12e92a585ef83 (patch)
treed147620e9e27658857a59e1198814821eeeef111 /src/node/README.md
parentd003c1b1ac2ac20416218737981187e899edb0ec (diff)
Automated documentation update (#257)
Automated documentation update [skip ci] Co-authored-by: github-actions <github-actions@github.com>
Diffstat (limited to 'src/node/README.md')
-rw-r--r--src/node/README.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/node/README.md b/src/node/README.md
index cb66356..5a5f64a 100644
--- a/src/node/README.md
+++ b/src/node/README.md
@@ -22,6 +22,24 @@ Installs Node.js, nvm, yarn, and needed dependencies.
| nvmInstallPath | The path where NVM will be installed. | string | /usr/local/share/nvm |
| nvmVersion | Version of NVM to install. | string | 0.39.2 |
+## Using nvm from postCreateCommand or another lifecycle command
+
+Certain operations like `postCreateCommand` run non-interactive, non-login shells. Unfortunately, `nvm` is really particular that it needs to be "sourced" before it is used, which can only happen automatically with interactive and/or login shells. Fortunately, this is easy to work around:
+
+Just can source the `nvm` startup script before using it:
+
+```json
+"postCreateCommand": ". ${NVM_DIR}/nvm.sh && nvm install --lts"
+```
+
+Note that typically the default shell in these cases is `sh` not `bash`, so use `. ${NVM_DIR}/nvm.sh` instead of `source ${NVM_DIR}/nvm.sh`.
+
+Alternatively, you can start up an interactive shell which will in turn source `nvm`:
+
+```json
+"postCreateCommand": "bash -i -c 'nvm install --lts'"
+```
+
---