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

ignores locally installed esformatter #74

Open
airtonix opened this issue Aug 25, 2016 · 5 comments
Open

ignores locally installed esformatter #74

airtonix opened this issue Aug 25, 2016 · 5 comments

Comments

@airtonix
Copy link

airtonix commented Aug 25, 2016

https://packagecontrol.io/packages/EsFormatter says:

You can either install esformatter globally or under your current project's node_modules folder. This complicates the setup slightly but you can configure things anyway you want.

So the situation is this:

~/Projects/foo/bar feature/baz*
❯ ls -al ./node_modules/esformatter/bin
total 12
drwxr-xr-x. 2 zeno.jiricek zeno.jiricek 4096 Oct 17  2015 .
drwxr-xr-x. 7 zeno.jiricek zeno.jiricek 4096 Aug 10 14:27 ..
-rwxr-xr-x. 1 zeno.jiricek zeno.jiricek 1491 Oct 17  2015 esformatter

Esformatter Settings are this:

{
    "format_on_save": true
}

Yet I get an alert window dialog saying:

It looks like esformatter is not installed.
Please make sure that it is installed globally or in project node_modules folder
@airtonix
Copy link
Author

airtonix commented Aug 25, 2016

Looks like this is happening because your code only tries to discover the global npm root.

Changing it to something like this should work:

def getNpmGlobalRoot():
    # determine NPM global root
    try:
        return subprocess.check_output(["npm", "root", "-g"]).rstrip().decode('utf-8')
    except:
        # NPM not installed or not accessible
        return None

def getNpmLocalRoot():
    # determine NPM local root
    try:
        return subprocess.check_output(["npm", "root"]).rstrip().decode('utf-8')
    except:
        # NPM not installed or not accessible
        return None

# Extend NODE_PATH to make globally installed esformatter requirable
npmRoot = getNpmLocalRoot() or getNpmGlobalRoot()

@airtonix
Copy link
Author

meh, even when i globally install esformatter it fails.

@ghost
Copy link

ghost commented Sep 1, 2016

Same here, it fails for globally installed esformatter. I think it might be happening because I am using nvm to install node?

@BennyTian
Copy link

same issues ...

@prusswan
Copy link

For Ubuntu/Mint it looks like only system npm (the one installed with apt-get) with global install of esformatter will work properly. It might work with nvm with some hacking of env configuration, but a proper fix is needed to work with yarn/nvm.

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

3 participants