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

Error: Cannot find module 'd:\Program' with gvim installed in "d:\Program Files (x86)\Vim" #68

Open
wangxxi opened this issue Oct 30, 2014 · 17 comments

Comments

@wangxxi
Copy link

wangxxi commented Oct 30, 2014

module.js:340
throw err;
^
Error: Cannot find module 'd:\Program'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:

could you please help ?

@maksimr
Copy link
Owner

maksimr commented Oct 30, 2014

Seems similar to #67

@maksimr
Copy link
Owner

maksimr commented Oct 30, 2014

@wangxxi what version of node and vim you use?

@wangxxi
Copy link
Author

wangxxi commented Oct 30, 2014

C:\Users\wangxi>node --version
v0.10.18

and

gvim with

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 27 2010 17:59:02)
Garbage after option argument: "-version"
More info with: "vim -h"

thanks.

@wangxxi
Copy link
Author

wangxxi commented Oct 30, 2014

tried the latest

C:\Users\wangxi>node --version
v0.10.33

still the same issue

seems the program does not handle well the case of windows path

  1. with \
  2. has space in it

thanks.

@maksimr
Copy link
Owner

maksimr commented Oct 30, 2014

Also it may be this issue.

Did you define path to js-beautify lib or use default?

@wangxxi
Copy link
Author

wangxxi commented Oct 30, 2014

at first I use the default, it has that error

then I copy the d:\Program Files (x86)\Vim\vimfiles\bundle\vim-jsbeautify\plugin\lib\js\lib\

to c:\lib (to avoid space)

and has the config like this

path=c:\lib\beautify.js

but still it show the same error

Error: Cannot find module 'd:\Program'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:2

it seems still looking for something in d:

I have put the _vimrc in

d:\Program Files (x86)\Vim\vimfiles\

and also the system user dir.

@maksimr
Copy link
Owner

maksimr commented Oct 30, 2014

@wangxxi Thanks!

What say command in vim?

:echo map(['$HOME/.editorconfig', '$HOME/.vim/.editorconfig'], 'expand(v:val)')

Maybe we does not find custom .editorconfig....

Try set config through vim

let g:config_Beautifier = {}
let g:config_Beautifier['js'] = {}
let g:config_Beautifier['js'].indent_size = '4'
let g:config_Beautifier['js'].path = '...'

@lenny0702
Copy link

I also got this issue, my environment is Win 7, node V 0.10
But my error is a little different in the disk part:
Error: Cannot find module 'C:\Program'

and as you say the command
:echo map(['$HOME/.editorconfig', '$HOME/.vim/.editorconfig'], 'expand(v:val)')
it's output is
image
seems it found the configure file , but still went wrong.

hopes you will help me. this plugin is really useful to me, Thanks!

@maksimr
Copy link
Owner

maksimr commented Jan 14, 2015

@lenny0702 Thanks for feedback.

Let's try to look at the problem from the top down.
I think error Error: Cannot find module 'C:\Program' throw here
path we pass from vim to node here.
Value for path we get here and here we escape quotes.

It will be cool 👍 if you try debug from js and find a place where broken path(if it is really broken).

@maksimr
Copy link
Owner

maksimr commented Jan 14, 2015

I tried reproduce it on Windows.

If put plugin to Program Files/...(where installed vim) then I get error but if I put it in User home directory($HOME/vimfiles/) then all work correct.

UPD.

Seems problem in space in the file path

@lenny0702
Copy link

yes, the problem is the space in file path, I think I kind of figure it out here.
I output your system call for running node.js, as shown below
image
If you run this in windows command line, you will get the same error which is shown in vim when running you plugin.
image
I think the problem is that in Windows when your command path include a space , backslash didn't solve the problem, you must keep the whole command in "" like this:
image
you can try it, may it solve!
I am still not familiar with your code, will be great if you can fix it, Thanks so much

@maksimr
Copy link
Owner

maksimr commented Jan 14, 2015

@lenny0702 yup, but quote path is not fully resolve problem because path contains slash(Program\ Files) which we should remove when we call system.
I don't understand how correct resolve path like this now, because manually remove slash is very ugly.

Thanks

@maksimr
Copy link
Owner

maksimr commented Jan 14, 2015

How workaround you can put plugin to C:\lennylan\vimfiles\plugin\

@maksimr maksimr added the bug label Jan 14, 2015
@maksimr
Copy link
Owner

maksimr commented Jan 14, 2015

Related #63

@lenny0702
Copy link

A little ugly indeed...
But change workaround works fine in my machine, and still, it would be better to fix it, because it's the default path for most window users.
I will investigate it to see if there is a better way to solve it and sync it here
Thanks for the reply.

1 similar comment
@lenny0702
Copy link

A little ugly indeed...
But change workaround works fine in my machine, and still, it would be better to fix it, because it's the default path for most window users.
I will investigate it to see if there is a better way to solve it and sync it here
Thanks for the reply.

@maksimr
Copy link
Owner

maksimr commented Jan 15, 2015

@lenny0702 do you use Cygwin?

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

No branches or pull requests

3 participants