Comments (4)
nodenv alters PATH
when the output of nodenv init
is sourced (or evaled depending on your setup)
So you just need to prepend ./node_modules/.bin
to PATH after you've invoked nodenv-init
from nodenv.
I have an idea for a plugin to make this possible, but at present it is not. It's not related to nodenv in any way. Local node_modules bins simply aren't on the path, and a non-nodenv installation isn't any different. There are alternatives, however.
-
Add
./node_modules/.bin
to yourPATH
. Though there are security reasons to avoid this. -
$(npm bin)/coffee
will run the local coffee. And npm-bin works anywhere in the project (not just at root). -
Use npm run-scripts. When an npm script is invoked via
npm run foo
, npm prepends$(npm-bin)
to yourPATH
. So scripts can invoke any locally installed bin without the need to prefix it."scripts": { "compile": "coffee" }
Now
npm run compile
will use your local coffee.
The complication for making a plugin for this is finding a way to make nodenv aware of all your local node_modules. It can't shim what it doesn't know about. Best I can think of so far, is that the plugin prepends $(npm bin)
to the PATH
during the exec
hook. But this would only work for modules that have been installed globally and are thus shimmed. So for any locally-installed bin, one would need to install it globally as well. Then the global shim would trigger nodenv, and the exec hook could prepend local bin path.
from nodenv.
Thanks for all the thoughts!
I'm in bucket #1. I've already added ./node_modules/.bin to my path, but I can't give them precedence over globally installed modules which nodenv pretends to my path.
Any thoughts on configuring where in the path the shims are added?
On Feb 11, 2016, at 5:22 AM, Jason Karns [email protected] wrote:
I have an idea for a plugin to make this possible, but at present it is not. It's not related to nodenv in any way. Local node_modules bins simply aren't on the path, and a non-nodenv installation isn't any different. There are alternatives, however.
Add ./node_modules/.bin to your PATH. Though there are security reasons to avoid this.
$(npm bin)/coffee will run the local coffee. And npm-bin works anywhere in the project (not just at root).
Use npm run-scripts. When an npm script is invoked via npm run foo, npm prepends $(npm-bin) to your PATH. So scripts can invoke any locally installed bin without the need to prefix it."scripts": {
"compile": "coffee"
}
Now npm run compile will use your local coffee.The complication for making a plugin for this is finding a way to make nodenv aware of all your local node_modules. It can't shim what it doesn't know about. Best I can think of so far, is that the plugin prepends $(npm bin) to the PATH during the exec hook. But this would only work for modules that have been installed globally and are thus shimmed. So for any locally-installed bin, one would need to install it globally as well. Then the global shim would trigger nodenv, and the exec hook could prepend local bin path.
—
Reply to this email directly or view it on GitHub.
from nodenv.
Closing since there's a workaround:
from nodenv.
Related Issues (20)
- Script to install/update nodenv on a shell (linux/mac) HOT 1
- How do things like yarn installs work within nodenv? HOT 3
- Support Corepack HOT 6
- Question: how to best run globally installed npm module? HOT 4
- Question: How would I go about removing nodenv and all node instances from a server? HOT 1
- Advice: nodejs latest release does not appear in $nodenv --list HOT 4
- Suggestion/Feature: LTS Version marker on the install list HOT 2
- strange undesired behavior when installing global dep HOT 1
- GPL License Compliance Issue HOT 2
- homebrew formula broken HOT 1
- Installing global package with yarn will not yield to a shim after rehash HOT 2
- `nodenv install` tries to use python and fails on MacOS Monterey 12.3 and later and fails HOT 6
- Support pnpm HOT 5
- In addition to .node-version, support .tool-versions and .nvmrc HOT 4
- Download fails with no error code
- No Debian / Ubuntu package available in the official repositories HOT 4
- Create Debian installation packages HOT 1
- Not respecting makefile HOT 2
- RBENV reference in the README HOT 2
- Documents HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodenv.