Skip to content

Error: Cannot find module 'typescript' #485

Closed
@Revadike

Description

Environment

Nuxt project info: 4:20:01 PM


  • Operating System: Linux
  • Node Version: v20.12.0
  • Nuxt Version: 3.12.4
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.7
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: devtools, ssr, app, runtimeConfig, build, modules, eslint, vite, dayjs, googleFonts, firebase, recaptcha, storyblok, piniaPersistedstate, compatibilityDate
  • Runtime Modules: (), @pinia/nuxt@0.5.2, @pinia-plugin-persistedstate/nuxt@1.2.1, @nuxtjs/google-fonts@3.2.0, dayjs-nuxt@2.1.9, @nuxt/eslint@0.5.1
  • Build Modules: -

Package

@nuxt/eslint

Reproduction

https://github.com/Revadike/reproduction

Describe the bug

Eslint needs typescript as dependency to work properly (in VSCode).

[Error - 3:31:03 PM] Calculating config file for file:///home/myproject/eslint.config.js) failed.
Error: Cannot find module 'typescript'
Require stack:
- /home/myproject/node_modules/@typescript-eslint/typescript-estree/dist/convert.js
- /home/myproject/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.js
- /home/myproject/node_modules/@typescript-eslint/typescript-estree/dist/parser.js
- /home/myproject/node_modules/@typescript-eslint/typescript-estree/dist/index.js
- /home/myproject/node_modules/@typescript-eslint/parser/dist/parser.js
- /home/myproject/node_modules/@typescript-eslint/parser/dist/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1152:15)
    at Module._load (node:internal/modules/cjs/loader:993:27)
    at c._load (node:electron/js2c/node_init:2:13801)
    at Module.require (node:internal/modules/cjs/loader:1240:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/myproject/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:30:25)
    at Module._compile (node:internal/modules/cjs/loader:1373:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1432:10)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)

Additional context

Our dev dependencies:

  "devDependencies": {
    "@date-io/dayjs": "^3.0.0",
    "@nuxt/devtools": "^1.0.6",
    "@nuxt/eslint": "^0.5.1",
    "@nuxt/types": "^2.17.2",
    "@nuxtjs/google-fonts": "^3.2.0",
    "dotenv": "^16.3.1",
    "eslint": "^9.9.0",
    "eslint-config-vuetify": "^1.0.0",
    "eslint-plugin-vue": "^9.27.0",
    "firebase-tools": "^13.0.1",
    "html-to-vue": "^1.4.0",
    "nuxt": "^3.8.2",
    "sass": "^1.69.5",
    "vite-plugin-vuetify": "^2.0.1",
    "vue": "^3.3.10",
    "vue-eslint-parser": "^9.4.0",
    "vue-router": "^4.2.5",
    "vuetify": "^3.4.7"
  },

Our eslint config:

import js from '@eslint/js'
import vue from 'eslint-plugin-vue'
import vuetify from 'eslint-config-vuetify'
import vueEslintParser from 'vue-eslint-parser'
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
  js.configs.recommended,
  ...vue.configs['flat/recommended'],
  {
    files: ['**/*.js', '**/*.vue'],
    languageOptions: {
      parser: vueEslintParser
    },
    ignores: ['dist/*'],
    plugins: { vue },
    rules: {
...

Logs

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions