Guest User

Untitled

a guest
Jun 18th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. # GUIXSD HANDLING NPM GLOBAL PACKAGES
  2.  
  3. Install package
  4.  
  5. ~~~
  6. # guix package -i node
  7. ~~~
  8.  
  9. Enable user handle global packages (npm)
  10.  
  11. ~~~
  12. $ mkdir /home/<user>/.vnode
  13. $ npm config set prefix "/home/<user>/.vnode"
  14. ~~~
  15.  
  16. Append to $PATH bins (npm)
  17.  
  18. ~~~
  19. $ echo PATH=/home/<user>/.vnode/bin:$PATH
  20. ~~~
  21.  
  22. Install npm
  23.  
  24. ~~~
  25. $ npm install npm
  26. ~~~
  27.  
  28. Now put on **/home/\<user\>/.vnode/lib/node_modules/.hooks/preinstall**
  29.  
  30. ~~~bash
  31. #/run/current-system/profile/bin/bash
  32. pkg_path=$PWD
  33.  
  34. function patch_shebang() {
  35. file=$1
  36. python_bin=`type -p python`
  37. python_bin=`type -p ruby`
  38. env_bin=`type -p env`
  39. bash_bin=`type -p bash`
  40.  
  41. if [ -n "$env_bin" ]; then
  42. sed -i -uE "s|^#!.+/env|#!${env_bin}|" $file
  43. elif [ -n "$bash_bin" ]; then
  44. sed -i -uE "s|^#!.+/bash|#!${bash_bin}|" $file
  45. elif [ -n "$python_bin" ]; then
  46. sed -i -uE "s|^#!.+/bash|#!${python_bin}|" $file
  47. elif [ -n "$ruby_bin" ]; then
  48. sed -i -uE "s|^#!.+/bash|#!${ruby_bin}|" $file
  49. fi
  50. }
  51.  
  52. files=`find $pkg_path -type f -exec grep -lE '^#!(.+ )' {} \;`
  53. for file in $files; do
  54. patch_shebang $file
  55. done
  56. ~~~
  57.  
  58. Allow run
  59. ~~~
  60. $ chmod a+rx /home/<user>/.vnode/node_modules/.hooks/preinstall
  61. ~~~
  62.  
  63. If everything it's ok, now run **npm install -g** and see this work's.
  64.  
  65. For local packages just copy the hook **myproject/node_modules/.hooks/preinstall**.
Add Comment
Please, Sign In to add comment