node commands don't work when run in quotes on windows #3005

krsch opened this Issue Dec 17, 2012 · 4 comments


None yet
2 participants

krsch commented Dec 17, 2012

It's more likely a windows bug, but npm should overcome it somehow.
How to reproduce:
C:>npm -v
C:>"npm" -v

    throw err;
Error: Cannot find module 'C:\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Tested on Windows 2008r2 server and Windows 7.
Vim plugins usually invoke all the commands in quotes, so this issue is very annoying.

I tried to explore this issue and discovered that %~dp0 returns cwd if %0 starts with " symbol. I have no idea how fix it.


krsch commented Dec 25, 2012

I think I have found a partial solution. If I prepend the following code to the generated .cmd file everything works.
For jslint:

@IF NOT EXIST "%~dp0\node_modules\jslint\bin\jslint.js" (
    @if "%~0" EQU %0 (call %~0 %*)
    goto :eof

This solution doesn't work if the filename contains spaces or if %0 contains wuotes in the middle. Though it should work for the most of npm packages.
Should I submit it as a pull request?


smikes commented Dec 21, 2014

I just tried to re-verify this with npm@2.1.14 on Windows 7 and it appears to have been fixed .. sometime in the last two years.

If you have the opportunity to test this with the current version of npm, can you check to see if vim plugins now work?

We are trying to clean up older npm issues, so if we don't hear back from you within a week, we will close this issue. (Don't worry -- you can always come back again and open a new issue!)



krsch commented Dec 26, 2014

Yes, now vim plugins finally work. Though upgrading npm on windows is not an easy task, but that's another issue.

krsch closed this Dec 26, 2014


smikes commented Dec 26, 2014

Yes, upgrading npm on Windows is a pain. I generally recommend people use option 3 from here: -- I hope you found that or something like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment