Closed emadzz closed 11 months ago
Information is not enough, please provide your eslint config file and the whole project structure.By the way, you'd better install eslint and prettier locally.
I have the same error but I'm not using yarn or Yarn Berry. I do not use global node modules either. I do not get why it is not searching the local project folder like I would expect.
No multi root or multi repo weirdness. Just a normal react-native project with config in the root and an index.js file that points to tsx files.
Error message:
Error: Cannot find module 'eslint'
Require stack:
- c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js
- c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js
- c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js
- c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js
-
Error: Cannot find module 'eslint'
Require stack:
- c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js
- c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js
- c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js
- c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js
-
at Module._resolveFilename (node:internal/modules/cjs/loader:1129:15)
at Function.s._resolveFilename (node:electron/js2c/utility_init:2:2786)
at Function.g.resolve (c:\Users\SKIKK\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:4:709)
at j4 (c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:209:36)
at zme (c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:185:599)
at vy (c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:209:3779)
at c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:209:6494
at Generator.next (<anonymous>)
at c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:1:796
at new Promise (<anonymous>)
at _y (c:\Users\SKIKK\.vscode\extensions\rvest.vs-code-prettier-eslint-5.1.0\dist\extension.js:1:616)
at wge (c:\Users\SKIKK\.vscode\extensions\rv (...)
.eslintrc.js:
module.exports = {
root: true,
extends: ['prettier', '@react-native-community'],
plugins: ['import', 'simple-import-sort', '@react-native-community'],
settings: {
'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'] },
'import/resolver': { typescript: { alwaysTryTypes: true } },
},
rules: {
'semi': ['error', 'never'],
'curly': ['error', 'multi-line'],
'linebreak-style': ['error', 'unix'],
'@typescript-eslint/no-unused-vars': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'import/no-unresolved': 'error',
'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
},
}
你好 ,您发给我的邮件我已经收到。
This issue is stale because it has been open for 14 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
你好 ,您发给我的邮件我已经收到。
Can confirm this is an issue with this extension. Tried installing the yarn sdk's for VSCode and installing eslint/prettier globally but it didn't work sadly
Yes, it's not related with yarn sdk or Yarn Berry.
I follow the steps @emadzz and reproduce it. To tell the truth, it's not caused by this Project. It's "prettier-eslint". In "prettier-eslint", it uses require.resolve
to search a module path, unfortunately , it doesn't search module under <user_workspace>/node_modules
as expected, this is why we meet "cannot find module XXX".
So, I try my best to fix it. To make everything simple, you can visit my release page, download the .vsix file, install the plugin from this file. I hope my work could help you. @ThaJay @davidfarinha
By the way, you have to pay attention to the version of some dependencies:
prettier
should be ^2.7.1
eslint-plugin-prettier
should be ^4.2.1
Describe the bug When trying to format a file with Prettier ESLint in a worksapce that uses Yarn Berry without the
nodeLinker: node-modules
, the extension fails with the following error trace:To Reproduce Steps to reproduce the behavior: (it doesn't have to be nestjs, but it already has eslint and prettier setup)
npm i -g @nestjs/cli
nest new my-project
code my-project
yarn set version berry
yarn
yarn dlx @yarnpkg/sdks vscode
.nodeLinker: node-modules
from.yarnrc.yml
yarn
Expected behavior The extension is able to locate the
eslint
module in Yarn Berry projects that don't use the node-modules linker. And the file is formatted successfully.Example Project This behaviour can be replicated using a new nestjs proejct that can be setup as described in the To Reproduce section.
Screenshots N/A
Versions (please complete the following information):
System Specifications (please complete the following information):
Additional context ESLint alone works fine at raising errors/warns of non-confirming code.