Trouble using nvm in any scripts

I installed nvm, as per the install instructions here, and it works fine if I type stuff in directly into the command line.

For example

$ nvm ls

And it runs fine. I understand that the nvm command works because of these couple of lines that are added to .profile:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm

But whenever running any script or trying to use the commands nohup, immortal, or dtach, it can't find the nvm command.

$ nohup nvm ls

nohup: nvm: No such file or directory

$ dtach -A /tmp/mk14 nvm install 14
dtach: could not execute nvm: No such file or directory

I'm new to FreeBSD (and loving it!), so maybe I don't understand how .profile works. Any ideas?
nvm is implemented using shell functions (set up with . $NVM_DIR/

These functions work with Bourne-like shells (sh, ksh, zsh, bash,...).

nohup(1) applies to commands (executable files) and not to shell script functions (which seem like commands, but are not).

What you are trying to do will not work, but you could create a shell script wrapper (executable file) to get what you want, e.g.:
$ mkdir -p $HOME/bin
$ cd $HOME/bin
$ cat - >mynvm <<EOF
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # Import the nvm functions
nvm $*
$ chmod 755 mynvm
$ export PATH="$PATH:$HOME/bin"
$ nohup mynvm ls
Make sure that $HOME/bin is added permanently to your PATH (edit $HOME/.profile. Also, set the PATH explicitly in the mynvm script to what you want.