question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier not found in project node_modules when using --no-bin-links

See original GitHub issue

Explain the Issue and Expected Behavior

In some scenarios [0] it is necessary to use the --no-bin-links option with yarn (and similar for npm) to prevent the creation of symlinks in the node_modules/.bin/ directory.

For projects that have to do this, SublimeJsPrettier currently fails to find Prettier in the project’s node_modules directory, since it currently relies on the presence of node_modules/.bin/prettier rather than looking for node_modules/prettier/prettier-bin.js.

It would be great to either:

  1. Check for node_modules/prettier/prettier-bin.js instead of node_modules/.bin/prettier
  2. Check for node_modules/prettier/prettier-bin.js as well as node_modules/.bin/prettier

Option (2) would likely mean a redundant check most of the time, but would be more resilient in case Prettier ever changed the location of their bin script within the package.

Prettier version

1.15.2

JsPrettier Plug-in Version

1.21.3

Platform Details

- Sublime Text Version: 3
- Sublime Text Build: Dev channel 3180
- Sublime Text Architecture: None shown on the ST about dialogue; not clear where to find
- Operating System Name: Windows
- Operating System Version: 10
- Operating System Architecture: x64

Generated Prettier command line arguments

N/A since:

JsPrettier [ERROR]: Ensure 'prettier' is installed in your environment PATH, or manually specify an absolute path in your 'JsPrettier.sublime-settings' file and the 'prettier_cli_path' setting.

Is the same behavior observed when run against Prettier directly?

N/A since this is about the plugin specifically.

The contents of your User/JsPrettier.sublime-settings file

No custom user settings.

The contents of your <project_name>.sublime-project file (if applicable)

No custom project settings.

Steps to reproduce the behavior

  1. mkdir test && cd test
  2. echo '--*.no-bin-links true' > .yarnrc
  3. yarn add prettier@1.15.2
  4. touch foo.js
  5. Open foo.js in Sublime Text that has this plugin installed
  6. Open ST command palette and type/select “JsPrettier: Format Code”
  7. Check ST console for errors

[0] For projects that use Vagrant for development, it’s common to have the project directory be shared from the Virtualbox VM back to the host using Virtualbox’s shared folders. However when the guest OS is Linux and the host Windows, any attempt to create a symlink in that shared folder will fail, since Virtualbox doesn’t yet handle them correctly (even now they are now supported in Windows 10). Most of the time this isn’t a problem since the project’s source directory won’t contain symlinks. However yarn/npm will create symlinks in the node_modules/.bin/ directory (since they see the guest OS supports symlinks) unless instructed not to via --no-bin-links or similar. As such, in these cases it’s necessary to force no bin links in .yarnrc, so that developers on all platforms have a working Vagrant environment.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jonlabellecommented, Nov 23, 2018

Makes sense. I’ll try to work this in shortly. Seems straight forward enough.

0reactions
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier not getting configured in VS Code - Stack Overflow
I am not able to configure "Prettier" into my VS Code. ... 4:16:59 pm] Cannot find module '\AppData\Roaming\npm\node_modules\prettier'.
Read more >
Check in your node_modules folder - seriesci blog
You could even go as far as telling npm not to create the symlinks at all by using the --no-bin-links flag. $ npm...
Read more >
Cannot find module 'prettier' error | bobbyhadz
This will add the prettier package to the development dependencies of your project. If the error is not resolved, try to delete your...
Read more >
server/node_modules/protobufjs/CHANGELOG.md - GitLab
#⃣ Fixed missing semicolon after 'extensions' and 'reserved' ... #⃣ Call npm with '--no-bin-links' when installing CLI deps, fixes #823
Read more >
Cannot find module 'prettier' error [Solved] - Reactgo
The prettier module is not installed in the correct project directory. Using the module without installing it in the project. Installed the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found