Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locally installed module's binaries to $PATH #86

Closed
jhermann opened this issue Jun 26, 2014 · 7 comments
Closed

Add locally installed module's binaries to $PATH #86

jhermann opened this issue Jun 26, 2014 · 7 comments

Comments

@jhermann
Copy link
Contributor

"activate" should add "‹envdir›/node_modules/.bin" to the $PATH, in front of "‹envdir›/bin".

@ekalinin
Copy link
Owner

  1. May by ‹envdir›/lib/node_modules/.bin (and not ‹envdir›/node_modules/.bin)?
  2. Just checked:
$ virtualenv --no-site-packages env
$ . env/bin/activate
$ pip install nodeenv
$ nodeenv 4 -p --prebuilt
$ npm -g install sitemap
sitemap@0.7.3 ~/env/lib/node_modules/sitemap
$ ls -a env/lib/node_modules/
.  ..  npm  sitemap

There is no any .bin directory in the env/lib/node_modules/.
When this directory is to be created?
How can i check it?

@jhermann
Copy link
Contributor Author

Try something that has a bin in its package.json, like gulp.

Also see https://www.npmjs.org/doc/package.json.html#bin

@LukeSkyw
Copy link

Same problem here for Karma. I add the package through npm, the package is installed in
env/lib/node_modules/karma
The binary is present but no link is created in env/bin so I can't use karma directly from the command line.
Is this a problem with karma package or with nodeenv ?

@chizcracker
Copy link

Check if your package is installed locally. If so, the binary will be in project_root/node_modules/package_name/bin
Simply, you can
export PATH=$NPM_CONFIG_PREFIX/../node_modules/.bin:$PATH
or rewrite activate script to include node_modules path to the $PATH.

If you don't like either, then install packages globally. Since your project is managed by nodeenv, installing global might be the easiest solution.
npm install -g package_name

@Jobava
Copy link

Jobava commented Apr 27, 2016

Hello, any progress on this issue?

How do people actually run nodeenv if the packages installed with npm are not in the PATH?

clrpackages pushed a commit to clearlinux-pkgs/nodeenv that referenced this issue Oct 18, 2016
…1.0.0

Version 1.0.0
-------------
- `--prebuilt` is default. See `# 161`_
- Added `--source` option
- Added support for the `ARM`. See `# 171`_
- Fixed issue with `$PATH`. See `# 86`_

.. _# 171: ekalinin/nodeenv#171
.. _# 161: ekalinin/nodeenv#161
.. _# 86: ekalinin/nodeenv#86
@bigsmoke
Copy link

With the current implementation, it is unpractical to use npm without -g. However, when installing packages from a project's package.json rather than a requirements file, npm -g also does not have the required result, because all the package dependencies from package.json will be installed below the package in virtualenv/lib/node_modules/<package_name>/node_modules. This comes down to being forced to put all your dependencies in a requirements file.

It would be extremely nice if packages installed through npm without -g (in project/node_modules/) would be in the $NODE_PATH and their binaries (in project/node_modules/.bin/) in the $PATH.

Any plans to making nodeenv modify virtual/bin/activate in such a way as to make this possible?

@jhermann
Copy link
Contributor Author

jhermann commented Jan 11, 2019

A local install of gulp creates this, thus the original request:

$ ls -l ./node_modules/.bin/gulp
lrwxrwxrwx 1 jhe jhe 19 Jan 11 17:20 ./node_modules/.bin/gulp -> ../gulp/bin/gulp.js

Or well, DID create. In a more recently created virtualenv I get different results.

For gulp, the way to go is npm install -g gulp-cli – but I don't know if all relevant packages follow that pattern to offer a *-cli package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants