Open jbolila opened 10 years ago
@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
.
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)
@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?
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
What is supposed to load on this lines:
JavaScript file which will beautify content for example ~/tmp/js-beautify/js/lib/beautify.js
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.
@jbolila try debug vim function and this. Maybe path
does not correct expanded ...
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.
@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
vim-jsbeautify/plugin/beautify.min.js
is failing on therequire(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
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]