In order to run project-specific executables like eslint and/or stylelint, it is typical to use either yarn run or npm run to use the installed version. However, Emacs currently doesn't know to use these executables, and will search for them in the normal path. For example, this means that the eslint style checks won't work unless the eslint executable is installed globally which is rarely the case.
Luckily, this is a solved problem. This PR adds a dependency on the add-node-modules-path package and uses it to append node_modules/.bin to the exec-path for any buffer that is in prog-mode.
Why prog-mode and not js-mode? Because there are often non-JavaScript source files in your project that nevertheless use tools written in JavaScript for them to work. An example of this is stylelint. It's writteni in JavaScript, but we want it to be on the exec-path for CSS files too; not just JavaScript files.
In order to run project-specific executables like
eslint
and/orstylelint
, it is typical to use eitheryarn run
ornpm run
to use the installed version. However, Emacs currently doesn't know to use these executables, and will search for them in the normal path. For example, this means that the eslint style checks won't work unless theeslint
executable is installed globally which is rarely the case.Luckily, this is a solved problem. This PR adds a dependency on the
add-node-modules-path
package and uses it to appendnode_modules/.bin
to theexec-path
for any buffer that is inprog-mode
.Why
prog-mode
and notjs-mode
? Because there are often non-JavaScript source files in your project that nevertheless use tools written in JavaScript for them to work. An example of this isstylelint
. It's writteni in JavaScript, but we want it to be on theexec-path
for CSS files too; not just JavaScript files.Before
After