Troubleshooting npm install failure in code-server app on TrueNAS Scale

Hey folks, I’m having a bit of trouble with the code-server app on my TrueNAS Scale setup. I got my repo up and running, but when I try to use npm, it’s not cooperating.

Here’s what happens when I run npm install:

user@appcontainer:~/myproject$ npm i
bash: npm: command not found

I attempted to fix it by installing nodejs and npm using the TrueNAS shell, but that led to more errors:

$ apt install -y nodejs npm
Error: Unable to change to root gid
Error: Initializing audit plugin failed
Error: Command not recognized

Has anyone encountered this issue? I’m looking for any suggestions on how to resolve the npm problem in the code-server app. Any help would be greatly appreciated!

I’ve dealt with this exact issue in my TrueNAS Scale setup. The problem stems from the containerized environment of code-server. What worked for me was using the Alpine package manager within the container.

First, access the container’s shell through the TrueNAS UI. Then run:

apk update
apk add nodejs npm

This should install both Node.js and npm. Verify with ‘node --version’ and ‘npm --version’.

If you’re still hitting snags, check your container’s network configuration. Ensure it has internet access and the correct DNS settings. Also, double-check your user permissions within the container.

Remember, changes to the container might not persist after restarts, so you may need to create a custom Dockerfile or use persistent volumes for a permanent fix.

hey Pete_Magic, ran into similar issue. try updating ur PATH variable in code-server. add this to ur .bashrc:

export PATH=$PATH:/usr/local/bin

then restart code-server. if that dont work, might need to manually install npm in the container. good luck!

I had a similar experience with code-server on TrueNAS Scale. The container environment was quite limited, and installing Node.js and npm inside the container proved to be the solution. I accessed the container’s shell via TrueNAS UI and ran the command apk add --no-cache nodejs npm. After verifying the installation with node --version and npm --version, everything functioned as expected. If problems continue, ensure the container has proper internet access, that the repositories are configured correctly, and that you have sufficient permissions to install packages.