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 '/home/current/working/directory/' #67

Open
jbolila opened this issue Oct 21, 2014 · 9 comments
Open

Error: Cannot find module '/home/current/working/directory/' #67

jbolila opened this issue Oct 21, 2014 · 9 comments

Comments

@jbolila
Copy link

jbolila commented Oct 21, 2014

vim-jsbeautify/plugin/beautify.min.js is failing on the require(path), any clue?

(js-beautify is working well on Node, and is in the latest version)

doesn't matter what is defined on the .editorconfig

{
  'jsx': {}, 
  'js': {'path': '/usr/lib/node_modules/js-beautify/js/lib/beautify.js', 'space-in-paren': 'true', 'indent_style': 'space', 'indent_size': '2', 'bin': 'node'}, 
  'json': {}, 
  'html': {'indent_style': 'space', 'indent_size': '2'}, 
  'css': {'indent_style': 'space', 'indent_size': '2'}
}

is always using the same path inside the bundle at load (/home/myhome/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1175)

[node: v0.10.32, npm: 2.1.4]

@maksimr
Copy link
Owner

maksimr commented Oct 21, 2014

@jbolila try copy '/usr/lib/node_modules/js-beautify/ to your local folder (for example ~/tmp and change path on ~/tmp/js-beautify/js/lib/beautify.js.

@jbolila
Copy link
Author

jbolila commented Oct 22, 2014

thanks @maksimr, but doesn't solve this issue:

echo g:config_Beautifier gives:

{
  'jsx': {}, 
  'js': {'indent_char': ' ', 'path': '~/tmp/js-beautify/js/lib/beautify.js', 'space-in-paren': 'true', 'indent_style': 'space', 'indent_size': '2', 'bin': 'node'}, 
  'json': {}, 
  'html': {'indent_char': ' ', 'path': '~/tmp/js-beautify/js/lib/beautify-html.js', 'indent_style': 'space', 'indent_size': '2'}, 
  'css': {'indent_char': ' ', 'path': '~/tmp/js-beautify/js/lib/beautify-css.js', 'indent_style': 'space', 'indent_size': '2'}
}

and the error:

module.js:340
    throw err;
          ^
Error: Cannot find module '/home/jbolila/'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at load (/home/jbolila/.dotfiles/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1175)
    at /home/jbolila/.dotfiles/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1543
    at Object.<anonymous> (/home/jbolila/.dotfiles/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1881)
    at Object.<anonymous> (/home/jbolila/.dotfiles/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1910)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

this is not a new system, i'm using this setup for many months now and always updating to the latest versions with Vundle. Something has changed on this plugin or in node.

one question, why the path isn't been effective?

(i have tried to copy the file beautify.js over the files inside the plugin folder, it stops to give the error, but don't do nothing on the target file)

@maksimr
Copy link
Owner

maksimr commented Oct 22, 2014

@jbolila Thanks for the info!

/home/myhome/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1175 this is vim plugin JavaScript file (not js-beautify).

The path you specify in the configuration says where are the files js-beautify

Can you roll back plugin(vim plugin) on some version behind?

@jbolila
Copy link
Author

jbolila commented Oct 23, 2014

Thanks, can you explain me just one more thing.

What is supposed to load on this lines:

     if (has("host-node")) {
        (function() {
            var fs = require("fs");
            load = function(path) {
                var context = {},
                    property;
                if (path.charAt(0) !== "/" && path.charAt(1) !== ":") {
                    path = global.process.cwd() + "/" + path
                }
                context = require(path);
..

the path starts empty on this block (in this case), and ends with the value of global.process.cwd() + "/". with this the context = require(path); fails.

Vim version 7.4.473 on Linux

@maksimr
Copy link
Owner

maksimr commented Oct 23, 2014

What is supposed to load on this lines:

JavaScript file which will beautify content for example ~/tmp/js-beautify/js/lib/beautify.js

@jbolila
Copy link
Author

jbolila commented Oct 23, 2014

quick and dirty fix:

 context = require('/home/jbolila/.vim/bundle/js-beautify/js/lib/beautify.js');

don't know why the path starts empty in the load method.

@maksimr
Copy link
Owner

maksimr commented Oct 23, 2014

@jbolila try debug vim function and this. Maybe path does not correct expanded ...

@jbolila
Copy link
Author

jbolila commented Oct 24, 2014

really thanks @maksimr, and here are the results of the debug:

  let opts = b:config_Beautifier[type]
  let path = get(opts, 'path', s:getPathByType(type))
  echom "PATH.0 IS '" . path . "' for type ". type
  let path = expand(path)
  echom "PATH.1 IS '" . path . "' for type ". type

and results in:

PATH.0 IS '/home/jbolila/.dotfiles/.vim/bundle/vim-jsbeautify/plugin/lib/js/lib/beautify.js' for type js
PATH.1 IS '' for type js

the file exists, and the expand function is doing something wrong. I'm using Vim version 7.4.473 on Arch Linux, maybe something with this version of Vim.

@maksimr
Copy link
Owner

maksimr commented Oct 24, 2014

@jbolila yup.

For me :echo expand('/home/jbolila/.dotfiles/.vim/bundle/vim-jsbeautify/plugin/lib/js/lib/beautify.js') work correct.

Maybe you have some plugin which redefine expand function...

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 23 2014 23:22:14)
Included patches: 1-307

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

2 participants