yasuyk / web-beautify

Format HTML, CSS and JavaScript/JSON by js-beautify
GNU General Public License v3.0
219 stars 21 forks source link

js-beautify not found #6

Open drewwells opened 10 years ago

drewwells commented 10 years ago

Even after installing js-beautify globally, I'm getting errors running this in EMACS. This may be because I use NPM. Can you add some notes about setting up the paths correctly in EMACS, so that this package can find js-beautify?

dentrinh commented 10 years ago

What is the issue exactly?

tacit7 commented 10 years ago

I think Im having the issue that drewwells was having. I downloaded js-beautify using the -g option, but emacs is having problems calling js-beautify. I get 'js-beautify not found' when I call web-beautify-js.

dentrinh commented 10 years ago

@tacit7 @drewwells Are you both still experiencing the issue? Have you verified that js-beautify is part of your PATH for Emacs? Could you provide some more information if you are still having issues, e.g. operating system, emacs version, error traces, etc.

tacit7 commented 10 years ago

@dentrinh I solved the issue, but I don't quite remember what I did to solve it. But I think I had to add the path to js-beautify to my emacs config.

Im an emacs newb, so I didnt know I had to do that.

drewwells commented 10 years ago

I added js-beautify to my path as well.

On Thu, Sep 11, 2014 at 10:12 AM, uriel notifications@github.com wrote:

@dentrinh I solved the issue, but I don't quite remember what I did to solve it. But I think I had to add the path to js-beautify to my emacs config.

Im an emacs newb, so I didnt know I had to do that.

Reply to this email directly or view it on GitHub: https://github.com/yasuyk/web-beautify/issues/6#issuecomment-55278341

gihankarunarathne commented 9 years ago

I got the same problem and I'm using Ubuntu 14.04 and node customize version v0.10.30 (which is downloaded and install in /opt/node/bin, then added it to PATH variable ).

I solved the problem using following steps;

  1. cd ~/.emacs.d/vendor
  2. git clone https://github.com/yasuyk/web-beautify.git
  3. cd web-beautify.git
  4. npm install js-beautify
  5. mv node_modules/.bin node_modules/bin
  6. Edit each file in node_modules/bin (such as css-beautify etc..) change "#!/usr/bin/env node" into "#!/opt/node/bin/node"

Note: if you added as "#!/opt/node/bin", it will give permission error.

  1. Added "(setq exec-path (append exec-path '("~/.emacs.d/vendor/web-beautify/node_modules/bin")))" into your emacs config file (.emcs or init.el)
  2. Setup web-beautify : https://github.com/yasuyk/web-beautify#manual

Cheers ... !!!

lvguowei commented 9 years ago

This happened to me on mac.

Solved it by doing the following:

anthonyteo commented 9 years ago

Hi all,

The same problem happened to me on my Mac. I am able to get the result of which js-beautify, which is /usr/local/bin/js-beautify, but I have no idea how to "add this dir into the Exec Path in emacs in customize page" as mentioned by @lvguowei. I know I have installed js-beautify on my system because I was able to run js-beautify -h as well, and I know Emacs understands M-x web-beautify-js too. The only problem is the said error when I run M-x web-beautify-js on Emacs...

Can someone please provide me detailed instructions as to how exactly I should add js-beautify to my path so that my Emacs understands it? Many thanks in advance.

dentrinh commented 9 years ago

@anthonyteo Assuming that the path to js-beautify is missing when you do "M-x getenv PATH", you can append the path to the exec path in your init file: http://emacswiki.org/emacs/ExecPath. Alternatively you can grab this: https://github.com/purcell/exec-path-from-shell.

anthonyteo commented 9 years ago

@dentrinh Thank you so much. Now it works. :)