Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode error: createRequire is not a function #2020

Closed
jiroler opened this issue May 13, 2020 · 4 comments
Closed

VSCode error: createRequire is not a function #2020

jiroler opened this issue May 13, 2020 · 4 comments
Labels
fix: user error issue was fixed by correcting the configuration / correcting the code package: parser Issues related to @typescript-eslint/parser

Comments

@jiroler
Copy link

jiroler commented May 13, 2020

Hello! I can not use typescript-eslint with VSCode, I get error

ESLint: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.js': createRequire is not a function Referenced from: {projectPath}/.eslintrc.js. Please see the 'ESLint' output channel for details.

.eslint.js

module.exports = {
    root: true,
    parser: '@typescript-eslint/parser',
    plugins: [
        '@typescript-eslint',
    ],
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended',
    ]
}

Workspace Settings

{
    "eslint.enable": true,
    "eslint.workingDirectories": [
        {"mode": "auto"}
    ],
     "eslint.validate": ["typescript", "typescriptreact"]
}

Actual Result (Error in ESLint output)

[Error - 10:36:07 AM] ESLint stack trace:
[Error - 10:36:07 AM] TypeError: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.js': createRequire is not a function
Referenced from: {projectPath}/.eslintrc.js
    at Object.resolve ({projectPath}/node_modules/eslint/lib/shared/relative-module-resolver.js:28:20)
    at ConfigArrayFactory._loadPlugin ({projectPath}/node_modules/eslint/lib/cli-engine/config-array-factory.js:992:39)
    at ConfigArrayFactory._loadExtendedPluginConfig ({projectPath}/node_modules/eslint/lib/cli-engine/config-array-factory.js:812:29)
    at ConfigArrayFactory._loadExtends ({projectPath}/node_modules/eslint/lib/cli-engine/config-array-factory.js:761:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody ({projectPath}/node_modules/eslint/lib/cli-engine/config-array-factory.js:702:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData ({projectPath}/node_modules/eslint/lib/cli-engine/config-array-factory.js:647:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at ConfigArrayFactory.loadInDirectory ({projectPath}/node_modules/eslint/lib/cli-engine/config-array-factory.js:495:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors ({projectPath}/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:355:46)

Additional Info

Command by shell works successfull

"scripts": {
    "eslint": "eslint . --ext .ts"
  }

Versions

package version
@typescript-eslint/parser 2.33.0
@typescript-eslint/eslint-plugin 2.33.0
TypeScript 3.9.2
ESLint 7.0.0
node 12.13.1
npm 6.9.0

Please, help me. Thank you

@jiroler jiroler added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels May 13, 2020
@jiroler
Copy link
Author

jiroler commented May 13, 2020

I am sorry. It is my local problem. I used old version of VSCode. Updating VSCode to latest version is solved problem.

@jiroler jiroler closed this as completed May 13, 2020
@jorgedavila25
Copy link

I'm seeing this issue in GCP's Cloudbuild. What about the old version of VSCode was fixed? Node version? Could be related.. Thanks

@bradzacher
Copy link
Member

If you're using ESLint v7 - it requires a minimum of node 10.12.0.
Any older than that, and it will not work.

Note that the above error isn't anything to do with our plugin - it's actually just ESLint failing to work on an old version of node. The message of "Failed to load plugin '@typescript-eslint'" is a red-herring.

The actual error:

error = createRequire is not a function
stack = eslint/lib/shared/relative-module-resolver.js:28:20

https://github.com/eslint/eslint/blob/0f1f5ed2a20b8fb575d4360316861cf4c2b9b7bc/lib/shared/relative-module-resolver.js#L28

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed triage Waiting for maintainers to take a look labels Jun 9, 2020
@jorgedavila25
Copy link

@bradzacher super helpful..Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2020
@bradzacher bradzacher added fix: user error issue was fixed by correcting the configuration / correcting the code and removed working as intended Issues that are closed as they are working as intended labels Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix: user error issue was fixed by correcting the configuration / correcting the code package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

No branches or pull requests

3 participants