简体   繁体   English

nodeenv —通过npm install -g安装时没有链接grunt吗?

[英]nodeenv — not linking grunt when installed via npm install -g?

I'm trying to use nodeenv but it doesn't seem like binaries are getting linked for npm installed modules. 我正在尝试使用nodeenv,但似乎并没有为npm安装的模块链接二进制文件。

$ mkvirtualenv venv
(venv)$ pip install nodeenv
(venv)$ nodeenv -p
(venv)$ deactivate
$ workon venv
(venv)$ which grunt
/usr/local/bin/grunt
(venv)$ npm install -g grunt
...
(venv)$ which grunt
/usr/local/bin/grunt
(venv)$ cd $WORKON_HOME/venv
(venv)$ ls bin
activate         activate.fish    easy_install     get_env_details  nodeenv          pip              postactivate     preactivate      python
activate.csh     activate_this.py easy_install-2.7 node             npm              pip-2.7          postdeactivate   predeactivate
### no grunt exe!
(venv)$ ls lib/node_modules
fsevents          grunt             mean              npm               recursive-readdir
### but it's in node_modules!

Am I doing something wrong? 难道我做错了什么?

You need to deactivate your venv and activate it then with source bin/activate 您需要先停用venv并将其激活,然后使用Source bin / activate

There are some node related environment changes. 有一些与节点相关的环境更改。 I found it trying integrate nodeenv in my jenkins build process. 我发现它试图在我的jenkins构建过程中集成nodeenv。

The other way is to make required environment by hands. 另一种方法是手工制作所需的环境。 For example Jenkins Shiningpanda don't allow to deactivate virtualenv (or I don't know how), so I used this workaround 例如,Jenkins Shiningpanda不允许停用virtualenv(或者我不知道如何),所以我使用了这种解决方法

pip install nodeenv
nodeenv --python-virtualenv

export NODE_VIRTUAL_ENV=$VIRTUAL_ENV
export PATH=$NODE_VIRTUAL_ENV/bin:$PATH
export NODE_PATH=$NODE_VIRTUAL_ENV/lib/node_modules
export NPM_CONFIG_PREFIX=$NODE_VIRTUAL_ENV

npm install -g bower
bower

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM