Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

This relative module was not found: * ./index.vue?vue&type=script&lang=ts& in ./pages/index.vue #819

Open
AxelBriche opened this issue Jul 7, 2021 · 5 comments

Comments

@AxelBriche
Copy link

AxelBriche commented Jul 7, 2021

Hello, on a fresh new install:

Capture_decran_2021-07-07_a_23 06 40

Capture d’écran 2021-07-07 à 23 27 42

@AxelBriche
Copy link
Author

AxelBriche commented Jul 7, 2021

Similar issue in the past nuxt/nuxt#8015

@hamishjohnson
Copy link

I'm having same issue, with similar setup (typescript, ssr (though static), tailwind )

@aseidma
Copy link

aseidma commented Dec 1, 2021

Just ran into this myself while updating dependencies.

Two steps were needed to fix this:

  1. Update both @nuxt/typescript-build and @nuxt/typescript-runtime to the latest versions as described in This relative module was not found: ./index.vue?vue&type=script&lang=ts& in ./pages/index.vue nuxt#8015
  2. Make sure you are using a typescript version that matches that of both packages (you can check in their respective package.json) - currently it is set to ~4.2.

@BurningDog
Copy link

I have the same issue, but solved it by removing node_modules and re-installed using yarn instead of npm. Somehow that worked!

Background

When running npm run dev on a newly-created Nuxt project (via npx) with Typescript support, I get this error:

This relative module was not found:
* ./index.vue?vue&type=script&lang=ts& in ./pages/index.vue

My global typescript version is 4.2 and my project's typescript version is also 4.2 (I also tried 4.5.5 for both). I manually installed @nuxt/typescript-runtime but that didn't help.

Others are still having the same problem:

Various solutions are proposed:

None of those solutions worked for me. It seems to be an issue with TypeScript versions but it's not clear what the issue is.

My versions:

  • node v16.10.0
  • npm 7.24.0

When I removed node_modules and tried with yarn (1.22.17), the install completed correctly, and yarn run dev did not show the error.

npm

I got these errors on npm install:

npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/eslint
npm WARN   dev eslint@"^8.4.1" from the root project
npm WARN   18 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^7.12.1" from [email protected]
npm WARN node_modules/eslint-config-standard
npm WARN   eslint-config-standard@"^16.0.3" from @nuxtjs/[email protected]
npm WARN   node_modules/@nuxtjs/eslint-config
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/eslint
npm WARN   peer eslint@"^7.12.1" from [email protected]
npm WARN   node_modules/eslint-config-standard
npm WARN     eslint-config-standard@"^16.0.3" from @nuxtjs/[email protected]
npm WARN     node_modules/@nuxtjs/eslint-config
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/eslint
npm WARN   dev eslint@"^8.4.1" from the root project
npm WARN   18 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^7.0.0" from [email protected]
npm WARN node_modules/eslint-plugin-promise
npm WARN   eslint-plugin-promise@"^5.1.1" from @nuxtjs/[email protected]
npm WARN   node_modules/@nuxtjs/eslint-config
npm WARN   1 more (eslint-config-standard)
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/eslint
npm WARN   peer eslint@"^7.0.0" from [email protected]
npm WARN   node_modules/eslint-plugin-promise
npm WARN     eslint-plugin-promise@"^5.1.1" from @nuxtjs/[email protected]
npm WARN     node_modules/@nuxtjs/eslint-config
npm WARN     1 more (eslint-config-standard)

npm why typescript gave this:

[email protected] dev
node_modules/@nuxt/typescript-build/node_modules/typescript
  typescript@"~4.2" from @nuxt/[email protected]
  node_modules/@nuxt/typescript-build
    dev @nuxt/typescript-build@"^2.1.0" from the root project
  peer typescript@">= 2.7" from [email protected]
  node_modules/@nuxt/typescript-build/node_modules/fork-ts-checker-webpack-plugin
    fork-ts-checker-webpack-plugin@"^6.1.1" from @nuxt/[email protected]
    node_modules/@nuxt/typescript-build
      dev @nuxt/typescript-build@"^2.1.0" from the root project
  peer typescript@"*" from [email protected]
  node_modules/@nuxt/typescript-build/node_modules/ts-loader
    ts-loader@"^8.0.17" from @nuxt/[email protected]
    node_modules/@nuxt/typescript-build
      dev @nuxt/typescript-build@"^2.1.0" from the root project

[email protected] dev
node_modules/typescript
  typescript@"^4.4.3" from @commitlint/[email protected]
  node_modules/@commitlint/load
    @commitlint/load@"^15.0.0" from @commitlint/[email protected]
    node_modules/@commitlint/cli
      dev @commitlint/cli@"^15.0.0" from the root project
  peer typescript@">=3.8 <5.0" from [email protected]
  node_modules/ts-jest
    dev ts-jest@"^27.1.1" from the root project
  peer typescript@">=2.7" from [email protected]
  node_modules/ts-node
    ts-node@"^9" from @endemolshinegroup/[email protected]
    node_modules/@endemolshinegroup/cosmiconfig-typescript-loader
      @endemolshinegroup/cosmiconfig-typescript-loader@"^3.0.2" from @commitlint/[email protected]
      node_modules/@commitlint/load
        @commitlint/load@"^15.0.0" from @commitlint/[email protected]
        node_modules/@commitlint/cli
          dev @commitlint/cli@"^15.0.0" from the root project
    peerOptional ts-node@">=9.0.0" from [email protected]
    node_modules/jest-config
      jest-config@"^27.5.1" from @jest/[email protected]
      node_modules/@jest/core
        @jest/core@"^27.5.1" from [email protected]
        node_modules/jest
          dev jest@"^27.4.4" from the root project
          peer jest@"^27.0.0" from [email protected]
          node_modules/ts-jest
            dev ts-jest@"^27.1.1" from the root project
        @jest/core@"^27.5.1" from [email protected]
        node_modules/jest-cli
          jest-cli@"^27.5.1" from [email protected]
          node_modules/jest
            dev jest@"^27.4.4" from the root project
            peer jest@"^27.0.0" from [email protected]
            node_modules/ts-jest
              dev ts-jest@"^27.1.1" from the root project
      jest-config@"^27.5.1" from [email protected]
      node_modules/jest-cli
        jest-cli@"^27.5.1" from [email protected]
        node_modules/jest
          dev jest@"^27.4.4" from the root project
          peer jest@"^27.0.0" from [email protected]
          node_modules/ts-jest
            dev ts-jest@"^27.1.1" from the root project
    peerOptional ts-node@">=9.0.0" from [email protected]
    node_modules/tailwindcss/node_modules/postcss-load-config
      postcss-load-config@"^3.1.0" from [email protected]
      node_modules/tailwindcss
        tailwindcss@"^2.2.2" from @nuxtjs/[email protected]
        node_modules/@nuxtjs/tailwindcss
          dev @nuxtjs/tailwindcss@"^4.2.1" from the root project
        peer tailwindcss@"1 || 2 || 2.0.1-compat || 3" from [email protected]
        node_modules/tailwind-config-viewer
          tailwind-config-viewer@"^1.6.2" from @nuxtjs/[email protected]
          node_modules/@nuxtjs/tailwindcss
            dev @nuxtjs/tailwindcss@"^4.2.1" from the root project
  peer typescript@">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" from [email protected]
  node_modules/tsutils
    tsutils@"^3.21.0" from @typescript-eslint/[email protected]
    node_modules/@typescript-eslint/eslint-plugin
      @typescript-eslint/eslint-plugin@"^5.4.0" from @nuxtjs/[email protected]
      node_modules/@nuxtjs/eslint-config-typescript
        dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
      peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from [email protected]
      node_modules/eslint-plugin-jest
        eslint-plugin-jest@"^25.3.0" from @nuxtjs/[email protected]
        node_modules/@nuxtjs/eslint-config
          @nuxtjs/eslint-config@"8.0.0" from @nuxtjs/[email protected]
          node_modules/@nuxtjs/eslint-config-typescript
            dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
    tsutils@"^3.21.0" from @typescript-eslint/[email protected]
    node_modules/@typescript-eslint/type-utils
      @typescript-eslint/type-utils@"5.12.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/eslint-plugin
        @typescript-eslint/eslint-plugin@"^5.4.0" from @nuxtjs/[email protected]
        node_modules/@nuxtjs/eslint-config-typescript
          dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
        peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from [email protected]
        node_modules/eslint-plugin-jest
          eslint-plugin-jest@"^25.3.0" from @nuxtjs/[email protected]
          node_modules/@nuxtjs/eslint-config
            @nuxtjs/eslint-config@"8.0.0" from @nuxtjs/[email protected]
            node_modules/@nuxtjs/eslint-config-typescript
              dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
    tsutils@"^3.21.0" from @typescript-eslint/[email protected]
    node_modules/@typescript-eslint/typescript-estree
      @typescript-eslint/typescript-estree@"5.12.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/parser
        @typescript-eslint/parser@"^5.4.0" from @nuxtjs/[email protected]
        node_modules/@nuxtjs/eslint-config-typescript
          dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
        peer @typescript-eslint/parser@"^5.0.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^5.4.0" from @nuxtjs/[email protected]
          node_modules/@nuxtjs/eslint-config-typescript
            dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
          peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from [email protected]
          node_modules/eslint-plugin-jest
            eslint-plugin-jest@"^25.3.0" from @nuxtjs/[email protected]
            node_modules/@nuxtjs/eslint-config
              @nuxtjs/eslint-config@"8.0.0" from @nuxtjs/[email protected]
              node_modules/@nuxtjs/eslint-config-typescript
                dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
      @typescript-eslint/typescript-estree@"5.12.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/utils
        @typescript-eslint/utils@"5.12.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^5.4.0" from @nuxtjs/[email protected]
          node_modules/@nuxtjs/eslint-config-typescript
            dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
          peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from [email protected]
          node_modules/eslint-plugin-jest
            eslint-plugin-jest@"^25.3.0" from @nuxtjs/[email protected]
            node_modules/@nuxtjs/eslint-config
              @nuxtjs/eslint-config@"8.0.0" from @nuxtjs/[email protected]
              node_modules/@nuxtjs/eslint-config-typescript
                dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
        @typescript-eslint/utils@"5.12.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/experimental-utils
          @typescript-eslint/experimental-utils@"^5.0.0" from [email protected]
          node_modules/eslint-plugin-jest
            eslint-plugin-jest@"^25.3.0" from @nuxtjs/[email protected]
            node_modules/@nuxtjs/eslint-config
              @nuxtjs/eslint-config@"8.0.0" from @nuxtjs/[email protected]
              node_modules/@nuxtjs/eslint-config-typescript
                dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
        @typescript-eslint/utils@"5.12.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/type-utils
          @typescript-eslint/type-utils@"5.12.0" from @typescript-eslint/[email protected]
          node_modules/@typescript-eslint/eslint-plugin
            @typescript-eslint/eslint-plugin@"^5.4.0" from @nuxtjs/[email protected]
            node_modules/@nuxtjs/eslint-config-typescript
              dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project
            peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from [email protected]
            node_modules/eslint-plugin-jest
              eslint-plugin-jest@"^25.3.0" from @nuxtjs/[email protected]
              node_modules/@nuxtjs/eslint-config
                @nuxtjs/eslint-config@"8.0.0" from @nuxtjs/[email protected]
                node_modules/@nuxtjs/eslint-config-typescript
                  dev @nuxtjs/eslint-config-typescript@"^8.0.0" from the root project

Yarn

No errors when installing with yarn.

yarn why typescript gives:

yarn why v1.22.17
[1/4] 🤔  Why do we have the module "typescript"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Reasons this module exists
   - "@nuxt#typescript-build" depends on it
   - Hoisted from "@nuxt#typescript-build#typescript"
info Disk size without dependencies: "57.14MB"
info Disk size with unique dependencies: "57.14MB"
info Disk size with transitive dependencies: "57.14MB"
info Number of shared dependencies: 0
=> Found "@commitlint/load#[email protected]"
info This module exists because "@commitlint#cli#@commitlint#load" depends on it.
info Disk size without dependencies: "61.75MB"
info Disk size with unique dependencies: "61.75MB"
info Disk size with transitive dependencies: "61.75MB"
info Number of shared dependencies: 0
✨  Done in 0.32s.

@twofingerrightclick
Copy link

twofingerrightclick commented Apr 17, 2022

Using yarn to install worked for me as well. I have spent 8 hours today trying to get typescript going in Nuxt. Works fine if you just create a little project using
"nuxt": "^2.15.8",
"@nuxt/types": "^2.15.8",
"@nuxt/typescript-build": "^2.1.0"

but the project I have was initially created with create-nuxt-app 4.0.0. I experimented by just creating a new app with the tool, and using npm to install resulted in the relative module not found or ts-loader not found errors, but with yarn everything good.
Very frustrating lol.
npm 7.23.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants