Due to the filesystem structure that guix follows, it is not possible to install npm packages globally, the following guide helps you configure a local folder for installing global npm packages
Either install it into user's guix profile using the following command:
$ guix pull
$ guix install node
Or install it system-wide by adding the line (specification->package "node") to your system's config file /etc/config.scm as shown below:
(operating-system
...
(packages
(append
(list
...
(specification->package "node")
...)
%base-packages))
...)
Reconfigure the system if installing node system-wide
$ guix pull
$ sudo guix system reconfigure /etc/config.scm
.vnode directory in home
directory and enable it
$ mkdir $HOME/.vnode
$ npm config set prefix "$HOME/.vnode"
.vnode directory to ~/.bashrc or
~/.zshrc and then source the file. It's recommended that you logout and log back in.
Otherwise, you'll need to source the directory everytime you need to use the npm.
$ echo "export PATH=$HOME/.vnode/bin:$PATH" >> ~/.bashrc
$ source ~/.bashrc
$ npm install -g npm
$HOME/.vnode/lib/node_modules/.hooks/preinstall
#/usr/bin/env bash
pkg_path=$PWD
function patch_shebang() {
file=$1
python_bin=`type -p python`
ruby_bin=`type -p ruby`
env_bin=`type -p env`
bash_bin=`type -p bash`
if [ -n "$env_bin" ]; then
sed -i -uE "s|^#!.+/env|#!${env_bin}|" $file
elif [ -n "$bash_bin" ]; then
sed -i -uE "s|^#!.+/bash|#!${bash_bin}|" $file
elif [ -n "$python_bin" ]; then
sed -i -uE "s|^#!.+/bash|#!${python_bin}|" $file
elif [ -n "$ruby_bin" ]; then
sed -i -uE "s|^#!.+/bash|#!${ruby_bin}|" $file
fi
}
files=`find $pkg_path -type f -exec grep -lE '^#!(.+ )' {} \;`
for file in $files; do
patch_shebang $file
done
$ chmod a+rx $HOME/.vnode/node_modules/.hooks/preinstall
npm install -g package-name
and install global packages into the newly created directory.
For local packages just copy the hook myprojectdir/node_modules/.hooks/preinstall.
Yours Truly,
Akuma X Machina