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

Failed to load parser '@typescript-eslint/parser' declared in 'BaseConfig': Cannot find module 'typescript' #12376

Closed
noel-schenk opened this issue Oct 4, 2019 · 7 comments
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint works as intended The behavior described in this issue is working correctly

Comments

@noel-schenk
Copy link

Tell us about your environment

Environment Info:

Node version: v10.16.3
npm version: v6.11.3
Local ESLint version: v6.5.1 (Currently used)
Global ESLint version: Not found
typescript-eslint/parser

Please show your full configuration:

{
  "author": "Eric MORAND <eric.morand@gmail.com>",
  "name": "twing",
  "description": "First-class Twig engine for Node.js",
  "keywords": [
    "browser",
    "compiler",
    "template",
    "twig",
    "twig-engine",
    "typescript"
  ],
  "version": "3.0.1",
  "homepage": "http://NightlyCommit.github.io/twing",
  "license": "BSD-2-Clause",
  "repository": {
    "type": "git",
    "url": "git://github.com/NightlyCommit/twing"
  },
  "main": "dist/cjs/main.js",
  "browser": "dist/es/browser.js",
  "module": "dist/es",
  "types": "dist/types/main.d.ts",
  "engines": {
    "node": ">=6.0.0"
  },
  "scripts": {
    "precover": "rimraf coverage .nyc_output",
    "postbuild:cjs": "replace-in-file '__VERSION__' $npm_package_version dist/cjs/**/*",
    "postbuild:es": "replace-in-file '__VERSION__' $npm_package_version dist/es/**/*",
    "pretest": "rimraf test/tests/types/dist && npm run build:cjs -- --sourceMap true",
    "pretest:browser": "npm run pretest",
    "pretest:types": "npm run pretest && rimraf test/tests/types/dist",
    "prepack": "npm run build && npm run bundle",
    "test": "npm run fastest:all",
    "test:browser": "npm run fastest:integration:browser",
    "test:docs": "cd docs && bundle exec jekyll build",
    "test:types": "tsc --project test/tests/types",
    "fastest:all": "tape 'test/tests/**/test.js' | tap-bail | tap-spec",
    "fastest:integration": "tape test/tests/integration/**/test.js | tap-bail | tap-spec",
    "fastest:integration:browser": "node test/tests/integration/browser.js | browserify - --basedir ./test -t [ stringify --extensions [.html .twig] ] | tape-run --render='tap-spec'",
    "fastest:unit": "tape 'test/tests/unit/**/test.js' | tap-bail | tap-spec",
    "cover": "nyc npm t",
    "coverage": "nyc report --reporter=text-lcov | coveralls",
    "build": "npm run build:cjs && npm run build:es && npm run build:types",
    "build:cjs": "rimraf dist/cjs && tsc --project . --module commonjs --outDir dist/cjs",
    "build:es": "rimraf dist/es && tsc --project . --module es6 --outDir dist/es",
    "build:types": "rimraf dist/types && tsc --project . --declaration true --emitDeclarationOnly true --outDir dist/types",
    "bundle": "browserify dist/cjs/browser.js -g uglifyify -s Twing -o dist/lib.min.js",
    "docs": "cd docs && bundle exec jekyll serve",
    "docs:install": "cd docs && bundle install --path vendor/bundle"
  },
  "dependencies": {
    "@types/luxon": "^1.4.0",
    "camelcase": "^4.1.0",
    "capitalize": "^1.0.0",
    "crypto-js": "^3.1.9-1",
    "esrever": "^0.2.0",
    "fs-extra": "^5.0.0",
    "htmlspecialchars": "^1.0.5",
    "iconv-lite": "^0.4.19",
    "is-integer": "^1.0.7",
    "is-number": "^5.0.0",
    "is-plain-object": "^2.0.4",
    "isobject": "^3.0.1",
    "levenshtein": "^1.0.5",
    "locutus": "^2.0.11",
    "luxon": "^1.19.3",
    "merge": "^1.2.1",
    "object-hash": "^1.2.0",
    "pad": "^2.0.3",
    "regex-parser": "^2.2.8",
    "runes": "^0.4.3",
    "snake-case": "^2.1.0",
    "source-map": "^0.6.1",
    "tmp": "0.0.33",
    "twig-lexer": "^0.6.3",
    "utf8-binary-cutter": "^0.9.2",
    "var-validator": "0.0.3"
  },
  "devDependencies": {
    "@types/locutus": "0.0.5",
    "@types/node": "^9.3.0",
    "@types/sinon": "^4.3.0",
    "@types/tmp": "0.0.33",
    "@typescript-eslint/parser": "^2.3.2",
    "browserify": "^16.2.3",
    "coveralls": "^3.0.0",
    "eslint": "^6.5.1",
    "fs-finder": "^1.8.1",
    "node-hook": "^1.0.0",
    "nyc": "^13.3.0",
    "replace-in-file": "^3.4.2",
    "rimraf": "^2.6.2",
    "sinon": "^6.3.4",
    "stringify": "^5.2.0",
    "tap-bail": "^1.0.0",
    "tap-spec": "^5.0.0",
    "tape": "^4.9.0",
    "tape-run": "^6.0.0",
    "typescript": "^3.1.3",
    "uglifyify": "^5.0.1"
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

sudo npm install eslint --save-dev
sudo npm install @typescript-eslint/parser --save-dev
sudo ./node_modules/.bin/eslint --init
? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? CommonJS (require/exports)
? Which framework does your project use? None of these
? Does your project use TypeScript? Yes
? Where does your code run? (Press <space> to select, <a> to toggle all, <i> to invert selection)Browser, Node
? How would you like to define a style for your project? Inspect your JavaScript file(s)
? Which file(s), path(s), or glob(s) should be examined? /home/noel/Documents/sync/twing/twing/src/**/*.ts
? What format do you want your config file to be in? JSON

What did you expect to happen?
Initializing ESLINT and after that checking the code.

What actually happened? Please include the actual, raw output from ESLint.

? What format do you want your config file to be in? JSON
Determining Config: 0% [------------------------------] 0.0s elapsed, eta 0.0s 

Failed to load parser '@typescript-eslint/parser' declared in 'BaseConfig': Cannot find module 'typescript'
Error: Failed to load parser '@typescript-eslint/parser' declared in 'BaseConfig': Cannot find module 'typescript'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/home/noel/Documents/sync/twing/twing/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/noel/Documents/sync/twing/twing/node_modules/@typescript-eslint/typescript-estree/dist/parser.js:18:25)
    at Module._compile (/home/noel/Documents/sync/twing/twing/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
@noel-schenk noel-schenk added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Oct 4, 2019
@kaicataldo
Copy link
Member

kaicataldo commented Oct 4, 2019

Can you share some more information about when you encountered this error? Did it occur while running eslint --init or did it occur when you ran ESLint after running the initializer? It looks like the former, but I just want to confirm.

@kaicataldo kaicataldo added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 4, 2019
@noel-schenk
Copy link
Author

It occurred while trying to do sudo ./node_modules/.bin/eslint --init

@kaicataldo kaicataldo added the core Relates to ESLint's core APIs and features label Oct 4, 2019
@kaicataldo
Copy link
Member

Thanks, and is typescript in your node_modules directory? Do you mind sharing the output of running npm ls typescript in the root directory of this project (where package.json is)?

@noel-schenk
Copy link
Author

I think it's not

noel@noel:~/Documents/sync/twing/twing$ npm ls typescript
twing@3.0.1 /home/noel/Documents/sync/twing/twing
└── (empty)

but it's part of the devDependencies

@kaicataldo
Copy link
Member

The initializer doesn't install typescript for you (see typescript-eslint/typescript-eslint#828 for more details). Might be a silly question, but have you tried after running npm install?

@noel-schenk
Copy link
Author

Ah okay I manually added typescript ... seems like that solved the problem
Thank you so much!

@kaicataldo
Copy link
Member

Glad you were able to solve it!

@kaicataldo kaicataldo added 3rd party plugin This is an issue related to a 3rd party plugin, config, or parser question This issue asks a question about ESLint works as intended The behavior described in this issue is working correctly and removed bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 5, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 4, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint works as intended The behavior described in this issue is working correctly
Projects
None yet
Development

No branches or pull requests

2 participants