aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorChuck Lantz <clantz@microsoft.com>2022-11-03 02:39:11 +0300
committerGitHub <noreply@github.com>2022-11-03 02:39:11 +0300
commitd003c1b1ac2ac20416218737981187e899edb0ec (patch)
tree0327278415156e0a5d5a7b42d8ec928c77fa16e6 /src/node
parentb7c70d3d9ba2c1dd698e9c5bce2f2727cc6a6d31 (diff)
Add missing notes
Diffstat (limited to 'src/node')
-rw-r--r--src/node/NOTES.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/node/NOTES.md b/src/node/NOTES.md
new file mode 100644
index 0000000..a6a4aba
--- /dev/null
+++ b/src/node/NOTES.md
@@ -0,0 +1,18 @@
+## 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'"
+```
+