0

I recently migrated from using node installed on my Ubuntu server to using NVM to manage my node, but the issue is the application I use on this server uses a .service file that executes with the path of the locally installed node, usr/bin/node. I have fixed this configuration by using the NVM path, but the issue with this is that the server node version can change (e.g. when updating my application with a newer node version). Because of this is there a good way to either symlink or insert some dynamic insertion as a part of the path?

Line:

ExecStart=/home/ghost-mgr/.nvm/versions/node/v14.17.0/bin/node /usr/bin/ghost r$

Full File:

[Service]
Type=simple
WorkingDirectory=/var/www/ghost
User=999
Environment="NODE_ENV=production"
ExecStart=/home/ghost-mgr/.nvm/versions/node/v14.17.0/bin/node /usr/bin/ghost r$
Restart=always

[Install]
WantedBy=multi-user.target
cphill
  • 197
  • 1
  • 1
  • 12

1 Answers1

0

You may use nvm-exec, but you need to define the NODE_VERSION

Environment="NODE_VERSION=v18.15.0"
ExecStart=/home/ghost-mgr/.nvm/nvm-exec node /usr/bin/ghost r$