piuccio / sublime-esformatter

JavaScript formatter plugin for Sublime Text
MIT License
28 stars 20 forks source link

cannot find mout/object/merge when trying to format #42

Closed jamesmortensen closed 9 years ago

jamesmortensen commented 9 years ago

I wasn't able to get esformatter working in Sublime, but after seeing the plugin has recently been updated, I tried installing it again.

Setting the format on save option in User settings did not do anything, but when I try changing the setting in defaults, I get the following error message:

Error (1):
module.js:340
    throw err;
          ^
Error: Cannot find module 'mout/object/merge'
    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 s (/Users/jem/Library/Application Support/Sublime Text 3/Packages/EsFormatter/lib/esformatter.js:2:142)
    at s (/Users/jem/Library/Application Support/Sublime Text 3/Packages/EsFormatter/lib/esformatter.js:2:122)
    at /Users/jem/Library/Application Support/Sublime Text 3/Packages/EsFormatter/lib/esformatter.js:9993:15
    at Object.<anonymous> (/Users/jem/Library/Application Support/Sublime Text 3/Packages/EsFormatter/lib/esformatter.js:10025:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

I do have a configuration file called .esformatter in the same directory as my package.json for a Node.js app.

piuccio commented 9 years ago

You probably have a global version of esformatter (or a local in that repository). Can you please check its version? It should be at least 0.5

I'll try and fix it regardless of what version you have installed

millermedeiros commented 9 years ago

BTW, I just released v0.6.0 which will try to locate a locally installed version of esformatter if available (so you can have multiple projects each one using a different version of esformatter)

millermedeiros commented 9 years ago

important to note that the local version search is based on the path of the config file (if you pass the --config option on the cli) or fallback to process.cwd()

piuccio commented 9 years ago

Thanks, I'll start using 0.6.0 soon. However I believe the current version of sublime esformatter is already using any local version, because it's doing a simple require('esformatter') thus relying on node's internal resolve mechanism.

piuccio commented 9 years ago

Anyway this issue should now be fixed

jamesmortensen commented 9 years ago

Okay, you're right. I had version 0.4.7 installed globally. I removed both it and the one I installed locally and then reinstalled 0.6.0 globally. I then had to remove the EsFormatter Sublime plugin and reinstall it. Afterwards, the code formatted.

However, it's not formatted as per the .esformatter rules. I have this file in the Node.js project folder in the same directory as package.json. Where does that have to be for the system to read it? Thanks.