How to install node.js, nvm, npm on QNAP (NAS) - node.js

in QNAP APP center has node.js 4.x and 0.8.X version
However, these two versions are too old, I hope we can install a newer version.
I try to login linux system installed through the command
https://www.ostechnix.com/install-node-js-linux/
nas seems to have removed some of the command, I checked it is Ubuntu but no apt-get, I can not install node.js through these comman
cat /proc/version
Linux version 3.4.6 (root#BuildServer36) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Thu Oct 26 11:01:49 CST 2017
like this
sudo apt-get install nodejs npm
-sh: sudo: command not found
apt-get install nodejs npm
apt-get: command not found
I have not tried to install the mongodb should have a similar problem
My nas model is TS-439 Pro ii

Or just go to qnapclub.eu a repository of “unofficial apps” - download it and install through the GUI in app center...
You have to select accept third party apps and you should be good to go..

I was straggling with the same issue on mine QNAP.
I found this tutorial: https://techblog.dorogin.com/running-nodejs-app-on-qnap-nas-via-pm2-3bdb838524e4 written by Sergei Dorogin.
Highly recommend you to install pm2 which is production manager for node.js
https://github.com/Unitech/pm2
It took me around 3hours to set up everything, because I'm not good with Linux

I haven't played with this yet, but it seems like using Container Station to install an official Node.js Docker image is the way to go. This gives you a complete preconfigured Linux environment to run Node in.

Related

Linux AWS still looking for uninstalled version of Node and of NPM

I'm fairly new to Linux systems, so sorry if the question is too basic. I am using Amazon Linux 2 AMI.
I had installed version 16.4.2 of NodeJS at the beginning and was giving me compatibilities issues. Hence I tried to uninstall it and then install version 14.15.5 (which was stable on my local dev).
To uninstall the new version, I ran the command sudo yum remove nodejs and it apparently uninstalled NodeJS. Then I installed the old version via first curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - and then sudo yum install -y nodejs (it said it was successful). But finally I ran the command node -v to only get:
-bash: /home/ec2-user/.nvm/versions/node/v16.4.2/bin/node: No such file or directory
So he's still looking for the version I uninstalled. How can I completely remove the new version and finally get the new version installed, please?
Thanks in advance!
For anybody arriving at this post: after uninstallation, everything I had to do was stopping and rebooting the instance. Then the old version was recognized.
Try exiting and reconnecting to the EC2 instance, it helps everytime. Also, if you haven't already upgraded the nodejs version you can upgrade using this link once done, exit the instance and reconnect, works everytime.

In WSL2: Ubuntu 20.04 for Windows 10 nodejs is installed but npm is not working

I am using WSL2: Ubuntu 20.04 in my Windows 10 operating system. I have installed nodejs using the command sudo apt-get install -y nodejs when I do node -v command I get v12.18.3
mrd#DESKTOP-2EO5K4H:/mnt/c/Users/musfi$ node -v
v12.18.3
but when I do npm -v command I get this below command
mrd#DESKTOP-2EO5K4H:/mnt/c/Users/musfi$ npm -v
-bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
I also do whereis command. Hope this will help to find solution.
mrd#DESKTOP-2EO5K4H:/mnt/c/Users/musfi$ whereis node
node: /usr/bin/node /usr/include/node /mnt/c/Program Files/nodejs/node.exe /usr/share/man/man1/node.1.gz
mrd#DESKTOP-2EO5K4H:/mnt/c/Users/musfi$ whereis npm
npm: /usr/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd /usr/share/man/man1/npm.1
I have tried almost all the stackoverflow solutions and github issues but nothing is worked for me.
Hope any kind soul has the solution to this problem. Thanks in advance.
Try this
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sudo apt install npm
Solution for following error:
-bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
Edit ~/.bashrc
Append at end of file:
# strip out problematic Windows %PATH%
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g')
Now npm init will work.
A better way is configuring /etc/wsl.conf in your Windows User directory.
Adding this into the /etc/wsl.conf, so Windows Path will not take the precedence
[interop]
appendWindowsPath=false
For more config details check the Microsoft Dev Blog here.
To install nodejs in WSL don't use apt follow Microsoft's guidance:
https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl
See also how to remove nodejs if you installed it via apt:
https://askubuntu.com/questions/786015/how-to-remove-nodejs-from-ubuntu-16-04
For npm to work under WSL1:
You may also need to disable ipv6 (or configure to prefer ipv4) - if you are hitting these issues.
Under WSL1 I disabled ipv6 on my main NIC & npm install immediately began working.
WSL2 Notes:
NB: if you use a VPN your container connectivity may be broken under WSL2 (e.g with Cisco AnyConnect) - the fix works but may no longer be needed under AnyConnect (WSL2 on a VPN now works for me after a recent update # end of July 2022)
I thought my WSL containers were running under WSL2 (I upgraded the WSL kernel with wsl --update) - while setting up Visual Studio with WSL I saw a WSL1 warning. You also have to upgrade containers:
wsl --set-version ubuntu-22.04 2
wsl --set-default-version 2
To get Visual Studio integration working properly with Ubuntu 22.04 in WSL you also currently have to upgrade gzip to install VS Code Server for x64 in WSL (code .: in the Linux terminal):
wget http://ftp.debian.org/debian/pool/main/g/gzip/gzip_1.12-1_amd64.deb
sudo dpkg -i ./gzip_1.12-1_amd64.deb
Finally I upgraded npm & everything works (choose one of the following commands):
nvm install-latest-npm
npm install -g npm#latest
Azure AD / CLI Notes
If you use nodejs with Azure Active Directory there seems to be an issue with the azure-cli forgetting credentials under WSL1 / WSL2 & persistently telling you to az login. In this case you need to run your local node development instances on Windows.
For all Unix/Linux/MacOS operating systems, I would always rather go with the "Node Version Manager". It normally works flawlessly on Linux and MacOS (and there's a Windows port for it as well) and enables a very simple way of installing node and npm correctly without the need of being root.
See here: https://github.com/nvm-sh/nvm
I can confirm here on my machine that it also works on Ubuntu 20.04 on WSL2.

I just installed Nodejs 14.4 from the site, but when I check the version in Command Prompt it shows version 8.10

title says it all. I have been using nodejs with npm for while now and it has been working fine, but I went to check the version and noticed it was an older one. Nodejs - version 8.10.0 and npm - version 3.5.2. I know there are more recent versions of each and like I said I went to download the new version of Nodejs and I got it. I have the path set up to its location in my Environment Variable. I'm not sure what I'm missing. Would love any help.
Edit: Forgot to mention on my original post that I am on Windows.
Edit2: So I was looking at it more and I am using the Ubuntu Bash Shell on muy windows computer. Whenever I check the version in the normal Windows Command Prompt it displays the right version, but when I check it in the Bash shell it is wrong. Any ideas why this happens?
The Node Version Manager. You can find it at https://github.com/coreybutler/nvm-windows
It allows you to easily install and manage multiple versions of node. Here's a snippet from the help:
Usage:
nvm install <version> Download and install a <version>
nvm use <version> Modify PATH to use <version>
nvm ls List versions (installed versions)
install and Usage:
nvm install 6.14.4 # or 10.10.0, 8.9.1, etc
and then
nvm use 6.14.4
So, I was able to solve my own issue
These two links were very important for solving my issue:
E: Unable to locate package npm
https://learn.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2
So basically after uninstalling nodejs I went and tried uninstalling and reinstalling my Ubuntu Bash shell. Once I had the Bash shell set up again I tried running the commands listed in the stackoverflow post I have listed above. (note: When you run the curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - line you need to adjust the "setup" version to 14.x) When I ran all the commands I was able to get my npm version up-to-date, but my nodejs was still being stuck at version 10.x. I tried running the install again on nodejs and thats when I noticed an error reading gpg: can't connect to the agent: IPC connect call failed I did some research on this error and foudn out my WSL1 would not allow it to update to the most recent version. Thats how I found my way to the Microsoft page that led to me needing to update my version of Windows to 1909 and then installing WSL2 through Power Shell. Everything is now up-to-date and working!
You could Uninstall both versions and reinstall the newer version. That should do it
Or better still download the NVM and follow the instructions from here
https://blog.logrocket.com/switching-between-node-versions-during-development/

Installing NodeJS on Linux RHEL(Release 6.6(Santiago)?

I'm trying to Install NodeJS on Linux RHEL(Release 6.6(Santiago)? Nothing seems to work. I download and extract the file(v.6.3.1). The I try to install with the command sudo yum install package_name. Nothing I try is working.
Red Hat packages a number of technologies via "Software Collections" including node.js 0.10 and 4.4. Details are here: https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/2/html-single/2.2_Release_Notes/index.html
Also, these are part of the RHEL subscription.

Path to Node.js Installation in Ubuntu

I am new to Ubuntu (linux).
I installed node.js for a project.
Recently I am getting this error on npm install.
Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
I found a stack link below as
Node pre error
Under the solution it asks for the directory where node.js is installed and currently i am clueless where the nodejs is installed.
Please help me on how can I locate the directory where node.js is installed.
Quick explanation
You have a version with -pre. Get rid of it and put the latest stable version from nodejs.org.
You can use which to locate a command. For your case, type which nodejs.
EDIT: The answer from your link is referring to the path of node source code, not the nodejs binary.
On Ubuntu, most software can be installed from the built-in repositories. This updates it for you (even if it's sometimes a bit outdated).
To install the stable version the Ubuntu way, install the nodejs-legacy package (after uninstalling your version):
sudo apt install nodejs-legacy
To use the latest, refer to https://askubuntu.com/a/663052/438156 (my answer), or https://askubuntu.com/a/711976/438156 (bit more involved, more the Ubuntu way).

Resources