Error installing nodejs in arch linux - linux

Okay so i just made a fresh install of nodejs package on archlinux using pacman. Command for the same was
sudo pacman -S nodejs npm . Now when i tried to run the same i am getting error as
node: error while loading shared libraries: libicui18n.so.57: Which pretty much means that libicu is either not there or not the correct version. The problem that i am facing is that it is not there in pacman. I tried
sudo pacman -S libicu, which returned not able to find the package. What is the right way to resolve this issue. FYI : just a note, i would prefer not to install from source and prefer using pacman for the same. If there is any other output that you need to know please comment below and will let you know about the same.
I am currently on manjaro i3 fresh install.

Just found out, The name for package in arch linux is icu and not libicu. Once that is installed node will start working fine.
Update
After using node for quite sometime i realised that a better way to install node is using NVM. It would install both node and npm locally and you get the option to manage multiple version.Installation is as simple as
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

This error is caused by installing node js and npm package modules with missing packages that are unsupported by your system how about you try this:
$ sudo pacman -Rsc -n nodejs
$ sudo pacman -Sy nodejs
$ sudo pacman -Sy npm

did you use testing repo?
If you enabled testing repositories, but later on decided to disable them, you should:
Remove/Comment them from /etc/pacman.conf
pacman -Syuu to "rollback" your updates from these repositories.
The second item is optional, but keep it in mind if you notice any problems.
Also you can install stable ver : pacman -S core/icu

You just need to update arch
sudo pacman -Syu

Related

Node versions do not match: node vs. sudo node -v ... WSL2 Ubuntu 22.04.1

As you can see in the image below, I see two different versions of node depending on which command I run.
I need the newer version, but npm sees the old version.
Many times I've removed, purged, reinstalled, etc.
I tried installing nvm as root and setting the node version there, but that didn't help either.
If I use apt install nodejs instead of nvm, it tells me that I already have the newest version, which it believes is 12.22.9.
How do I get npm to recognize the newer version (18.12.1) of node that I installed via nvm?
It is because you have a different version of the Node.js which is installed for the root and that particular user.
First, you need to uninstall Node.js:
sudo apt-get remove nodejs
or
sudo npm rm npm -g
If you have any problem with the above commands, then after running which node command, go to that directory, and run the following commands:
rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
Do the same thing for the current user if needed.
The default Ubuntu/Debian package manager does not have the latest Node.js, and that's why whenever you try to install Node.js with apt install nodejs it says you have the latest version.
According to the official Node.js documentation, for installing the latest version, you should follow these steps:
Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
P.S: No need to run npm or node with sudo. Therefore, I highly recommend you to not use every command with sudo.

Is there a way to update visual-studio-code-bin which is installed from the arch wiki

visual-studio-code-bin is installed from the arch wiki. The only way I know how to actually update the software is reinstalling it again from the arch wiki which is tedious and inconvenient.
Any help is appreciated
Old post with a lot of split information so for anyone who finds this later, you have 2 choices:
Install the open source version of visual studio code from the official repos.
Install the official Microsoft binary version via the AUR that contains some proprietary code from Microsoft that is not available in the fully open version (e.g. some debugging some languages).
Info on how to do this can be found in the wiki.
It depends on how you installed vscode. If you did sudo pacman -S code, then the solution is to run it again. But if you did yay -S visual-studio-code-bin, then you should run THIS command again.
The best way to use VS Code on Arch is to use the open source version on the community repos. Which you can install by doing
sudo pacman -S code
visual-studio-code-bin is the proprietary binary which can be installed from the Arch User Repository.
If for some reason you want to go for the latter approach, you can either use an AUR helper or manage everything manually.
You can see the Arch Wiki's page on AUR helpers which shows the different options you have: https://wiki.archlinux.org/index.php/AUR_helpers
You can use these helpers to help manage your updates just like you would on pacman.
Here's how you would do things manually: https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_and_upgrading_packages
Just as a warning, AUR helpers are not supported by Arch Linux and the manual approach, though less user friendly is the recommended way by the Arch Wiki to manage your AUR Packages.
First a short version:
Simply run
sudo pacman -Sy
sudo pacman -S visual-studio-code-bin
The longer explanation:
Getting the right version of vscode
First of all, "code" and "visual-studio-code-bin" are two different packages. "code" is an open-source release and "visual-studio-code-bin" is an Microsoft-branded release. One of the major differences is that "code" doesn't support any Microsoft Extensions like C/C++, to my knowledge. This information can be found in the arch wiki: https://wiki.archlinux.org/title/Visual_Studio_Code#Installation. For more detailed information about the differences I'll refer you to the vscode repository: https://github.com/microsoft/vscode/wiki/Differences-between-the-repository-and-Visual-Studio-Code
By running "sudo pacman -S code" you (unintentionally) uninstall "visual-studio-code-bin" and install "code" because of wired some decency conflict.
So if you want to update/install "visual-studio-code-bin" run:
sudo pacman -S visual-studio-code-bin
This should fix any Problems with no functioning Microsoft-Extensions
Of course if you want to sick to the open-source version you can use
sudo pacman -S code
Fixing your Problem with not updating to the right version
I have to admit this took me ages. I had two machines, one with an freshly installed version of geruda Linux (an arch based distro) and an six moth old version of geruda Linux. Both had vscode installed. At the time of writing this the current version of vscode is 1.59.0-1. Interestingly the my old machine, witch had vscode version 1.58.0-1 installed didn't know that there was an newer version. The newer machine was aware of the the newer version. An simply running pacman -S visual-studio-code-bin didn't change anything. This hinted my to the problem of an not synchronized package database. And forcefully synchronizing the database with
sudo pacman -Sy
did the trick for me. For a more detialed information I would redirect you to the man pages: https://archlinux.org/pacman/pacman.8.html or this thread https://bbs.archlinux.org/viewtopic.php?id=117765. After running this command you only need to install vscode with "sudo pacman -S visual-studio-code-bin" or "sudo pacman -S code" to get the newest version of vscode
As rightly said by #AlexanderHD27 code is open source and vscode is microsoft official version but it is not open source. though code is more like an experimental version of of vscode; however, you can install code directly in archlinux using sudo pacman -S code but for the the vscode you have to clone the repository from github and install in the following way:
git clone visual-studio-code-bin
then cd visual-studio-code-bin and makepkg -si
remember if you don't have git installed you can do that using sudo pacman -S git. As for the update; code is updated during system full update but vscode is not updated. So, you have to cd into the directory again and do git pull the makepkg -si again.
As KamilCuk and Aviad mentioned there is no visual-studio-bin package, since it is a aur package you can use yay (AUR helper) to get a updateable version. For more information about yay see: https://github.com/Jguer/yay.
Install yay
sudo pacman -S --needed base-devel git
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
cd ..
rm -rf yay
Install visual-studio-code-bin with yay
# install
yay -S visual-studio-code-bin
If you installed vscode via pamac manager in manjaro, try this:
pamac update
To update with the cloned AUR directory.
First update pacman database:
pacman-Sy
Then in the AUR directory you can update the AUR to the latest version with:
git pull
Then update dependencies with:
makepkg -s
Finally you install it:
makepkg -i
==> WARNING: A package has already been built, installing existing package...
==> Installing package visual-studio-code-bin with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...
Packages (1) visual-studio-code-bin-1.73.1-1
Total Installed Size: 324.26 MiB
Net Upgrade Size: 29.66 MiB
:: Proceed with installation? [Y/n]

Update Node.js: Error while updating Node.js on Mac

I am using mac. I have currently installed Node.js 4.4.3
Aleeshas-MacBook-Air:~ aleesha$ node -v
v4.4.3
I want to update Node.js to it's latest version by following these steps.
First I tried to execute: brew update. However, I was getting the below error when I executed the command:
brew update Error: /usr/local is not writable. You should change the
ownership and permissions of /usr/local back to your user account:
sudo chown -R $(whoami) /usr/local
So after searching for solution on Google, I ran this command: sudo chown -R $(whoami) /usr/local
After that I again executed the brew update command. I think it was successfully executed since I didn't see any error message. Last few lines on the command prompt were:
==> Migrating HOMEBREW_REPOSITORY (please wait)...
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew! Homebrew no longer needs to have ownership of /usr/local.
If you wish you can
return /usr/local to its default ownership with: sudo chown
root:wheel /usr/local Aleeshas-MacBook-Air:~ aleesha$
However after this step when I execute the upgrade command, it failed.
Aleeshas-MacBook-Air:~ aleesha$ brew upgrade node
Error: node not installed
Aleeshas-MacBook-Air:~ aleesha$
I am not sure what exactly needs to be done here.
Thanks
EDIT: Executed brew doctor to check for system anomalies.
Aleeshas-MacBook-Air:~ aleesha$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3-config
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5-config
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m-config
Warning: No developer tools installed.
Install the Command Line Tools:
xcode-select --install
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/node/android-ifaddrs.h
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/libplatform/libplatform.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h
You didn't install Node using Homebrew, use this gist to uninstall your current installation of Node.
And then:
brew update && brew install node
It seems like you didn't install nodejs through brew. If you installed Node without brew, brew doesn't recognize it. I had the same issue until I realised that I installed Node with Node Version Manager. Make sure you installed it using Brew.
brew list
Will show you the things brew installed.

Nodejs installed without npm?

I've just installed nodejs on Debian 7 - by apt-get install nodejs.
Nodejs seems to be working fine, but when I enter "npm" I get "command not found".
"which nodejs" points to "usr/bin" and there it is - nodejs, but there is no npm file, what went wrong?
I found a few solutions, but all of them are related to Macs
BTW, "usr/local/bin" directory is empty I believe everything should install right there?
You have several options.
If you want to continue using Debian packages, you could install npm (debian maintainers have it in a separate package).
apt-get install npm
If you want to just install npm, you can use this modification of Maxime's answer:
curl -L https://npmjs.org/install.sh | sudo sh
(the -L is needed to make curl follow redirects.)
Finally, you may wish to use a different package source.
For some Linux distributions (Debian/Ubuntu and RedHat/CentOS), the latest node version provided by the distribution may lag behind the stable version. Here are instructions from NodeSource on getting the latest node, which includes npm and avoids using the problematic nodejs alias
Install npm
curl -L https://npmjs.org/install.sh | sudo sh
(the -L is needed to make curl follow redirects.)
and check version
npm -v
Node.js is easy to install in Linux
create a directory nodejs inside /usr/local/lib
download nodejs
move downloaded tar.xz file inside /usr/local/lib
extract the tar.xz file and rename as like node-v8.9.4
setup environment
cd ./etc/profile.d
ls
sudo touch nodejs-env.sh
sudo atom nodejs-env.sh
where atom is my favourite editor; you can use your editor.
copy and paste below code inside nodejs-env.sh and save
export NODEJS_HOME=/usr/local/lib/nodejs/node-v8.9.4
export PATH=$NODEJS_HOME/bin:$PATH
restart you machine.
done
There were several methods to install node.js on your debian. But I prefer this one:
Setup with Debian (as root):
apt-get install curl
curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
Then install with Debian (as root):
apt-get install --yes nodejs
After that, relaunch your terminal and type "npm" in your terminal.
The problem you're facing is due the need of super user rights during the installation. As others mentioned, you could do it via the sudo command and the manual installer.
Either way, there're several ways to install node in *unix platforms in a safer way without the need of super user rights using NVM (Node Version Manager).
Steps:
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
$ nvm install 0.10
Also, you can find different techniques to install node and npm without having to sudo.

When I run node, nothing happens, the same with forever

I installed both node.js and forever.js and when I run them in my terminal (bash on Ubuntu 14.04), nothing happens.
So, it looks like:
#node
#
or
#forever
#forever --help
#forever listall
#
Everything else not node-related runs fine.
There was something wrong with apt-get, so when installing node, it didn't actually install node, but it did put a program in the path that did seemingly nothing.
I uninstalled it with
apt-get purge node
Then, I downloaded the 64-bit linux binary from here: http://nodejs.org/download/
And I extracted it with tar -xvf filename, then I set that directory/bin to the path with:
PATH=$PATH:/directory/to/node/bin
And now it works fine. The forever issue was because the node installed wasn't node at all, but instead a 30kb program of some sort, I don't know.
Here's the information about the program that was installed via apt-get install node:
Package: node
Priority: optional
Section: universe/hamradio
Installed-Size: 38
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Debian Hamradio Maintainers <debian-hams#lists.debian.org>
Architecture: all
Version: 0.3.2-7.4
Depends: ax25-node
Conflicts: nodejs-legacy
Filename: pool/universe/n/node/node_0.3.2-7.4_all.deb
Size: 1284
MD5sum: 7385a0f5916e03d9143459ca4706f0ec
SHA1: bf7aa087db81475636897ff39de344754ce1415b
SHA256: 9756770f771bcc4183cffa622f89e21a585be96bd4de27024b0a7cb167f310ad
Description-en: Amateur Packet Radio Node program (transitional package)
The existing node package has been renamed to ax25-node. This transitional
package exists to ease the upgrade path for existing users.
Description-md5: 1278ed271672fd829c99361f93f468da
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
So, I also found that the correct way to install node with apt-get is apt-get install nodejs.
I had the same issue, and I think it was caused because I naively apt-get installed node first. Doing a
sudo apt-get purge node
Followed by the instructions on the web here (https://github.com/nodesource/distributions):
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
fixed the issue for me. node doesn't exist, but nodejs does and other tools work (like slap) now.
EDIT: On one server I updated, node did exist. Not sure exactly what order things need to happen in, but whatever...
I was having this issue, I found that to solve the issue, I needed to remove the node file within /usr/sbin/node (found with which node) and replace it with a hard link to /usr/bin/nodejs (found with which nodejs)
ln /usr/bin/nodejs /usr/sbin/node
Just run nodejs command on your terminal after installing nodejs package.
It will give you the JavaScript prompt or interpreter.
The problem you are having is that apt-get installed NodeJS under the binary nodejs. Also when you do a npm install forever -g it also expects the binary to be node.
To verify this you can do a
% which forever
lrwxrwxrwx 1 root root 39 Jan 25 21:34 /usr/local/bin/forever -> ../lib/node_modules/forever/bin/forever
to find the location of the forever script.
Then check the node binary it's trying to execute.
% vim /usr/local/lib/node_modules/forever/bin/forever
#!/usr/bin/env node
This /usr/bin/env node needs to be changed to /usr/bin/env nodejs.
But to bypass this problem you should definitely look into using upstart.
http://howtonode.org/deploying-node-upstart-monit

Resources