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

Clearer documentation about setting node environment for sublime to what prettier was installed with #26

Closed
mlunoe opened this issue Mar 15, 2017 · 8 comments

Comments

@mlunoe
Copy link
Contributor

mlunoe commented Mar 15, 2017

After installing prettier and following the instructions I was hitting this issue:

/Users/ml/.nvm/versions/node/v4.4.4/lib/node_modules/prettier/bin/prettier.js:5
const fs = require("fs");
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

I wasn't sure what the problem was. After some digging, I found that I needed to have my node environment for sublime (for me project specific) as prettier was installed with. Setting this in my .sublime-project file solved it for me:

  "settings": {
    "js_prettier": {
      "prettier_cli_path": "/Users/ml/.nvm/versions/node/v4.4.4/bin/prettier",
      "node_path": "/Users/ml/.nvm/versions/node/v4.4.4/bin/node"
    }
  }

This was not super obvious to me. Could this be documented clearer somewhere?

Related issue: prettier/prettier#99 (comment)

@mlunoe
Copy link
Contributor Author

mlunoe commented Mar 15, 2017

The problem was that my environment (Sublime) was running a different version of node than what I used to install prettier with (and use in my project). So I had to point to sublime to use the same version of Node for its environment as I am using for prettier for it to work.

@mlunoe
Copy link
Contributor Author

mlunoe commented Mar 15, 2017

Related issue: #5

@mlunoe
Copy link
Contributor Author

mlunoe commented Mar 15, 2017

@jonlabelle, why are you closing this?

@jonlabelle
Copy link
Owner

jonlabelle commented Mar 15, 2017

So I had to point to sublime to use the same version of Node for its environment as I am using for prettier for it to work.

Please contribute the documentation you feel is approprate by making a pull request.

Thanks.

@jonlabelle jonlabelle reopened this Mar 15, 2017
mlunoe added a commit to mlunoe/SublimeJsPrettier that referenced this issue Mar 16, 2017
Explicitly stating where to set the node environment for Sublime Text to make it work for nvm.
Fixes issue jonlabelle#26
@mlunoe
Copy link
Contributor Author

mlunoe commented Mar 16, 2017

PR created

@jonlabelle
Copy link
Owner

Done.

@lock
Copy link

lock bot commented Aug 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
@jonlabelle
Copy link
Owner

See solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants