Encountered this error while setting up an NPM library through symlinking with npm link
in the library directory, followed by linking it in the Vue+Vite application using npm link <library name>
.
A crucial detail to note is that Vite played a significant role in triggering this error, as it originated from vite-plugin-eslint
.
The issue was resolved by including the include
key for the eslint options:
vite.config.js
import eslint from 'vite-plugin-eslint';
import path from 'path';
// note: `path` may require node v16+ due to `node:path` import
...
export default defineConfig({
plugins: [
eslint({
// eslint attempts to lint external directories symlinked via `npm link` without explicit path resolve
include: [
`${path.resolve(__dirname, '')}/**/*.js`,
`${path.resolve(__dirname, '')}/**/*.vue`,
],
}),
By referring to the documentation, you'll notice that the default eslint()
function without any specified options (as per their recommendation) includes include: ['**/*.ext'],
. Therefore, the solution lies in replacing **/
with
/explicit/path/to/root/of/your/project/
.
In theory, one could also utilize the exclude
key within the eslint options to prevent it from linting external folders. However, this approach may not be ideal when working with multiple developers, as predicting their directory structure becomes challenging.