moll / vim-node

Tools and environment to make Vim superb for developing with Node.js. Like Rails.vim for Node.
http://www.vim.org/scripts/script.php?script_id=4674
Other
807 stars 59 forks source link

Use npm package require-relative to find module path #41

Open feix760 opened 7 years ago

feix760 commented 7 years ago

Many errors: Can't find file "XXXXXX" in path We can use require-relative to eaily get real path

moll commented 7 years ago

I suspect that's because the package resolution algo I wrote for Node.vim isn't seeking for modules recursively up the chain. 😇 I should fix that as I occasionally hit that issue myself, too. As for require-relative, that's a Node module and Node.vim doesn't actually run any of its logic in JavaScript. :)

feix760 commented 7 years ago

We can use system('node vim-node.js') to exe require-relative for get path, i wrote one at https://github.com/feix760/vim-javascript-gf

tomarrell commented 6 years ago

I've written a small plugin that uses the package.json to resolve Node Path Relative modules https://github.com/tomarrell/vim-npr and is configurable on a project-by-project basis.

It may help out for your use case.