all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* GUIX HANDLING NPM PACKAGES: TIPS
@ 2018-06-16  1:35 Jovany Leandro G.C
  0 siblings, 0 replies; only message in thread
From: Jovany Leandro G.C @ 2018-06-16  1:35 UTC (permalink / raw)
  To: help-guix

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-16  1:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-16  1:35 GUIX HANDLING NPM PACKAGES: TIPS Jovany Leandro G.C

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.