loeeeee / immich-in-lxc

Install Immich in LXC with optional CUDA support
30 stars 3 forks source link

Issue with npm: command not found #29

Closed martiperez closed 4 days ago

martiperez commented 4 days ago

The ./install.sh script shows that NPM is not installed.

ERROR: Node.js is not installed.
[ . . .]
HEAD is now at 230eff4e1 chore: version v1.115.0
+ install_immich_web_server
+ cd /home/immich/source
+ '[' '!' -z '' ']'
+ cd server
+ npm ci
./install.sh: line 183: npm: command not found

I've ran the install.sh with sudo (so that is not an issue), and I know npm is installed...

immich@immich:~/immich-in-lxc# npm -v
**10.8.2**

immich@immich:~/immich-in-lxc# which npm
/root/.nvm/versions/node/v20.17.0/bin/npm

Any hints on where the problem can be? I'm on Ubuntu 24.04

loeeeee commented 4 days ago

It seems like you install the npm using the incorrect user, root. However, to allow immich user to use npm command, you need to follow the npm installation part as the user immich.

If you have anything still unclear, please feel to follow up. 😃

martiperez commented 4 days ago

Wow! Thans for your super-quick answer! Actually... Yes, I'm currently trying to install with root since I was having the exact same issues with the user immich... (I was just trying to debug, that's why you see the root user)

Let me recreate the issues with the immich user and I'll edit this comment accordingly :)

loeeeee commented 4 days ago

You are welcome @martiperez 😃

Ubuntu 24.04 is tested and should be good for the script.

Actually... Yes, I'm currently trying to install with root since I was having the exact same issues with the user immich... (I was just trying to debug, that's why you see the root user)

If you have a brief understanding of Ubuntu and the scripts, this should be fairly doable. Several little changes in the script, and you can make it work with root user, but it is just extra hassle.

immich@immich:~/immich-in-lxc# which npm
/root/.nvm/versions/node/v20.17.0/bin/npm

Here, in the snippet you provided, you can see that the npm command that immich user is trying to call is located in root's home directory, which might have some permission issues, and resulting in goofy behaviors.

I would strongly recommend installing the node.js in user immich's home directory, by doing the npm install part as the user immich. However, since you already installed the node.js things as root, after installing those again as user immich, you might need to change something related to $PATH in /home/immich/.bashrc.

The expected behavior is as follow.

immich@Colusa:~/immich-in-lxc$ npm -v
10.8.2

immich@Colusa:~/immich-in-lxc$ which npm
/home/immich/.nvm/versions/node/v20.17.0/bin/npm

And, my /home/immich/.bashrc is as follow.

... # Something else that does not seem to be related

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
martiperez commented 4 days ago

Thank you very much for your help, @loeeeee !

In the end, it turns out I was just running stuff with the wrong users... (mostly I just provided sudo access to the immich user and was running everything with that, which kept creating problems (one of them being this NPM one...).

To resolve furhter doubts, I modified a bit the documentation and created a pull request for it https://github.com/loeeeee/immich-in-lxc/pull/30

As a bonus for your help and for other peers as well, I also added a section for Intel Quick Sync transcoding (which is super easy to install as well! 😄 )

Again, thank you very much!

loeeeee commented 2 days ago

Thank you very much for your help, @loeeeee !

In the end, it turns out I was just running stuff with the wrong users... (mostly I just provided sudo access to the immich user and was running everything with that, which kept creating problems (one of them being this NPM one...).

To resolve furhter doubts, I modified a bit the documentation and created a pull request for it #30

As a bonus for your help and for other peers as well, I also added a section for Intel Quick Sync transcoding (which is super easy to install as well! 😄 )

Again, thank you very much!

You are welcome. Enjoy your Immich! 👍🏼