npm软件包在全球范围内-适用于所有项目的1个解决方案?

时间:2018-07-16 15:49:58

标签: node.js npm gulp ansible vagrant

有什么解决方案可以将所有运行npm链接的项目都使用npm吗?

我使用VCCW 〜/ .npmrc

prefix = ${HOME}/.npm-packages

npm安装

# Install npm packages
- name: Place a ~/.npmrc
  become: yes
  template:
    src: templates/.npmrc
    dest: "{{ ansible_env.HOME }}/.npmrc"
- name: Install npm packages
  become: yes
  npm:
    name: "{{ item }}"
    global: yes
    executable: /usr/bin/npm
  with_items: "{{ vccw.npms | default([]) }}"
  ignore_errors: yes

bash_profile

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

if [ -d "${HOME}/.bash.d" ] ; then
  for f in "${HOME}"/.bash.d/*.sh ; do
    source "$f"
  done
  unset f
fi

.bash.d / vccw.sh

... export PATH=$HOME/.npm-packages/bin:$PATH ...

这是一些npm测试

vagrant@mpsss:~$ npm ls
/home/vagrant
└── (empty)

vagrant@mpsss:~$ npm list -g --depth=0
/usr/lib
├── gulp-cli@2.0.1
...
-rw-rw-r--  1 vagrant vagrant   32 Jul 16 15:38 .npmrc
vagrant@mpsss:~$ sudo ls /root/.npm-packages
ls: cannot access '/root/.npm-packages': No such file or directory
vagrant@mpsss:~$ sudo ls /vagrant/.npm-packages
ls: cannot access '/vagrant/.npm-packages': No such file or directory

这是npm gulp输出:

vagrant@mpsss:~$ gulp
[15:49:30] Local gulp not found in ~
[15:49:30] Try running: npm install gulp

0 个答案:

没有答案