help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GUIX HANDLING NPM PACKAGES: TIPS


From: Jovany Leandro G.C
Subject: GUIX HANDLING NPM PACKAGES: TIPS
Date: Fri, 15 Jun 2018 18:35:55 -0700

Hi community, this maybe can help someone, a little tutorial
for working with npm packages.


1) Enable user handle global packages (npm)

~~~
$ mkdir /home/<user>/.vnode
$ npm config set prefix "/home/<user>/.vnode"
~~~

2) Append to $PATH, npm bins

~~~
$ echo PATH=/home/<user>/.vnode/bin:$PATH >> ~/.bashrc
~~~

3) Install npm

~~~
$ npm install npm
~~~

4)Now put on
**/home/\<user\>/.vnode/lib/node_modules/.hooks/preinstall**:

~~~
#/run/current-system/profile/bin/bash
pkg_path=$PWD

function patch_shebang() {
 file=$1
 python_bin=`type -p python`
 python_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
~~~

5) Allow run 
~~~
$ chmod a+rx /home/<user>/.vnode/node_modules/.hooks/preinstall
~~~

If everything it's ok, now run **npm install -g** and see this work's.

For local packages just copy the hook to
**myproject/node_modules/.hooks/preinstall**.

Be libre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]