Comments (21)
Seems to work for me:
C:\Program Files>node --version
v0.10.32
C:\Program Files>which node
'which' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files>which node
'which' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files>npm i -g which
C:\Program Files\nodejs\which -> C:\Program Files\nodejs\node_modules\which\bin\
which
[email protected] C:\Program Files\nodejs\node_modules\which
└── [email protected] ([email protected])
C:\Program Files>which node
C:\Program Files\nodejs\node.EXE
Is it perhaps using a different which
? What happens when you type which which
?
from node-which.
C:\>which which
C:\Users\%USER%\AppData\Roaming\npm\which.CMD
Oddly enough, which node is returned blank too.
C:\>which node
C:\>
But, this works:
C:\>node --version
v4.2.2
C:\>
from node-which.
Try this:
echo %PATH%
node -p process.execPath
Thanks.
from node-which.
C:\>echo %PATH%
D:\Product\TerminalEmulators\cmder\cmder_1.2.1\vendor\conemu-maximus5;D:\Product\TerminalEmulators\cmder\cmder_1.2.1\vendor\conemu-maximus5\ConEmu;"D:\Product\nano\nano";"C:\Windows\system32";"C:\Windows";"C:\Windows\system32\wbem";"C:\Windows\System32\WindowsPowerShell\v1.0";"C:\Program Files\TortoiseSVN\bin";"C:\Windows\SUA\common";"C:\Windows\SUA\usr\lib";"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin";"C:\Program Files\SlikSvn\bin";"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\";"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\";"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\";"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\";"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\";"C:\Program Files\Microsoft SQL Server\100\DTS\Binn\";"C:\Python27";"C:\Windows\System32\WindowsPowerShell\v1.0\";"C:\Program Files\SourceGear\Common\DiffMerge\";"C:\Program Files\Microsoft\Web Platform Installer\";"C:\Program Files\Sublime Text 3";"C:\Program Files (x86)\Git\cmd";"c:\Program Files\Oracle\VirtualBox\";"C:\Program Files\Perforce";"C:\Program Files (x86)\Bitvise SSH Client";"C:\Program Files\nodejs\";"C:\Program Files (x86)\nodejs\";"C:\HashiCorp\Vagrant\bin";"C:\Program Files\Boot2Docker for Windows";"C:\Program Files (x86)\Git\bin";"C:\ProgramData\chocolatey\bin";"C:\Program Files\Mercurial\";"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin";"D:\Product\MingW\mingw64\bin";"D:\Product\MingW\mingw64\libexec\gcc\x86_64-w64-mingw32\4.9.1";"C:\Program Files (x86)\GitExtensions\";"C:\Go\bin";"C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\";"C:\Program Files (x86)\Notepad++\";"C:\Program Files\Oracle\VirtualBox";"D:\Product\redis\Redis_2_4_11\x64";D:\Product\Javascript Frameworks\JSLint\jsl-0.3.0-win32\jsl-0.3.0;C:\Users\%user%\AppData\Local\atom\bin;"C:\Users\%user%\go\bin";"C:\Go\bin";C:\msysgit\git;C:\Users\%user%\AppData\Roaming\npm
C:\>node -p process.execPath
C:\Program Files (x86)\nodejs\node.exe
That's what I get. Apologies for how messy that is. Also, I replaced my domain account with %user% so that it's not posted here. But, other than that, that output is unedited.
from node-which.
I was interested that C:\Program Files\Java\jre1.8.0_40\bin
was absent from that path output.
I added it to the beginning of my system path, but I still receive the same output
C:\>which java
C:\>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
So, that doesn't appear to be the issue.
from node-which.
Note that if you change an environment variable you usually have to restart the command prompt, or in some cases, restart the computer. (Since this is windows.)
from node-which.
I'm aware of that issue and restarted the terminal (command prompt) between changes.
I'm no longer at the office, but I'll attempt to step through the which code on Monday to see if I can find the issue.
Thanks Isaac
from node-which.
I'm still digging into this, but this is the first thing that I've run into.
I created a test app.js which makes a which call and then did a break down into the which.js src.
On line 80, p is being set to:
'D:\\Proto\\whichTest\\"C:\\Program Files\\Java\\jre1.8.0_40\\bin"\\java'
Which is a concatenation of the test directory and the actual directory that java resides in.
I'm still digging around and hope to find where it's going awry momentarily.
from node-which.
Maybe the isAbsolute library isn't processing the test path correctly?
from node-which.
No, the issue isn't the isAbsolute call. I see now that you only use that for a test on what's passed in for the command argument.
The issue, appears to be how node's path.resolve handles double quotes.
I replaced line 80 of the current source, which is:
var p = path.resolve(pathEnv[i], cmd)
with
var p = isWindows ? path.resolve(pathEnv[i].replace(/"/g,""), cmd) : path.resolve(pathEnv[i], cmd);
and before line 108, I added a new variable for clean path (cP) so that:
var p = path.join(pathEnv[i], cmd)
reads:
var cP = isWindows ? pathEnv[i].replace(/"/g,"") : pathEnv[i];
var p = path.join(cP, cmd)
This fixed the issue for me. If you're okay with my solution, I can create a pull request. Or, if you want to just make a change, I'm okay with that too.
from node-which.
Ah! Great digging on this, thanks! So, the issue is having something in the env.PATH
that is quoted.
I'd rather replace it at each step, instead of all at once like suggested here.
Can you try this patch and see if it fixes your issue? https://gist.github.com/isaacs/271f41848f5782fba70a
from node-which.
I'll give it a try and let you know the results.
from node-which.
I wonder if it's possible to have a ;
in a file name if it's quoted, on Windows. That could make this break really interestingly. Also, if you have "
in a folder name, how does that show up in the Path environ?
from node-which.
The pathPart.substr(1,-1)
doesn't return the parts of the string that we need.
I believe that you want: pathPart.slice(1, -1)
from node-which.
With that change to both places where you assign pathPart, the patch works for me.
from node-which.
Right, slice, not substr.
I'll write up a test and land this in the next day or two. If you want it to land sooner, you can write the test and send as a PR. (Feel free to steal my work, especially since you actually just made it work ;)
from node-which.
As far as semi-colons go, it does appear that they are valid for file names per this MSDN article. Double quotes are reserved though, and would not normally be in a directory or file name.
from node-which.
No, in a day or two is fine. I appreciate your help and the library. Thanks!
from node-which.
Note: I ran into this while attempting to use selenium-standalone, which suffers from this if you use quoted directories in your path. So, I'll let them know of the update when you do push out the change.
from node-which.
This should be working on the latest release.
from node-which.
Thank you!
from node-which.
Related Issues (20)
- [BUG] `process.env.PATH` can be undefined on Windows
- 'node-which' is not recognized... HOT 1
- Antivirus/Malware report HOT 8
- Windows tests fail on linux because writing to process.env is implicitly converted to a string HOT 2
- which sync cannot work on windows HOT 1
- [Windows] File extension always in capital letters HOT 1
- Error: Cannot find module '../' HOT 3
- Resolving paths wrong in git bash on windows HOT 1
- Feature request: option to avoid throwing in whichSync HOT 1
- cannot install HOT 2
- Failed to parse past path entries on D: HOT 1
- Doesn't find executables in case-sensitive directory on Windows
- 160x slower than GNU which (~500ms vs. 3ms) HOT 3
- Support modern async/Promise usage
- Does not install under raspberry pi (arm32) HOT 4
- [BUG] Callback is part of promise chain HOT 2
- npm which function fails to get full path to an executable in macOS within an Electron app running in production mode but, works fine in development mode HOT 5
- [FEATURE] nothrow option for async which HOT 2
- [FEATURE] command -v is preferable (usually) to which HOT 3
- [BUG] Unable to invoke `which` from Windows 11's Terminal HOT 2
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 node-which.