Prettier not found in project node_modules when using --no-bin-links
See original GitHub issueExplain 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:
- Check for
node_modules/prettier/prettier-bin.js
instead ofnode_modules/.bin/prettier
- Check for
node_modules/prettier/prettier-bin.js
as well asnode_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
mkdir test && cd test
echo '--*.no-bin-links true' > .yarnrc
yarn add prettier@1.15.2
touch foo.js
- Open
foo.js
in Sublime Text that has this plugin installed - Open ST command palette and type/select “JsPrettier: Format Code”
- 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:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Makes sense. I’ll try to work this in shortly. Seems straight forward enough.
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.