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

Could not map moduleDetection force when running npm run prepack #297

Closed
fornazaric opened this issue Jun 21, 2024 · 6 comments
Closed

Could not map moduleDetection force when running npm run prepack #297

fornazaric opened this issue Jun 21, 2024 · 6 comments

Comments

@fornazaric
Copy link

fornazaric commented Jun 21, 2024

Hello,

I've been running @nuxt/module-builder in version 0.5.5 for some time now, but when i tried updating to 0.8.0 the error written later popped up.
I'm now upgrading to 0.6.0 only and face the same issue

I already tried:

  • Updating to vue-tsc 2.X
  • Changing the tsconfig file
  • Removing the one from our test directory
  • Removing most of the module.ts file

Here's the error:

Could not map moduleDetection force

[2:44:11 PM]  ERROR  module is a string value; tsconfig JSON must be parsed with parseJsonSourceFileConfigFileContent or getParsedCommandLineOfConfigFile before passing to createProgram

  at createProgram (node_modules/typescript/lib/typescript.js:123997:15)
  at synchronizeHostDataWorker (node_modules/typescript/lib/typescript.js:148933:15)
  at synchronizeHostData (node_modules/typescript/lib/typescript.js:148829:7)
  at Object.getProgram (node_modules/typescript/lib/typescript.js:149005:5)
  at getProgram (node_modules/@volar/typescript/lib/getProgram.js:34:19)
  at Object.set (node_modules/@volar/typescript/lib/getProgram.js:28:29)
  at Object.createProgram (node_modules/vue-tsc/out/index.js:61:23)
  at emitVueTscV1 (node_modules/mkdist/dist/index.mjs:394:28)
  at async getVueDeclarations (node_modules/mkdist/dist/index.mjs:358:7)
  at async mkdist (node_modules/mkdist/dist/index.mjs:526:35)



[2:44:11 PM]  ERROR  module is a string value; tsconfig JSON must be parsed with parseJsonSourceFileConfigFileContent or getParsedCommandLineOfConfigFile before passing to createProgram

I tried changing my tsconfig, resetting it to the one in the starter app, but nothing changes.

I think the problem might come from the module definition file:

  import {
      addComponentsDir,
      createResolver,
      defineNuxtModule,
      installModule
  } from '@nuxt/kit'
  import type { ModuleOptions } from '@nuxt/schema'
  
  export default defineNuxtModule<ModuleOptions>({
      meta: {
          name: 'redacted',
          configKey: 'redacted'
      },
      // Default configuration options of the Nuxt module
      defaults: {},
      async setup(_options, nuxt) {
          const resolver = createResolver(import.meta.url)
          nuxt.options.build.transpile.push(resolver.resolve('./runtime'))
  
          nuxt.hook('nitro:config', async (nitroConfig) => {
              nitroConfig.publicAssets ||= []
              nitroConfig.publicAssets.push({
                  dir: resolver.resolve('./runtime/public'),
                  maxAge: 60 * 60 * 24 * 365 // 1 year
              })
          })
  
          nuxt.options.alias['#redacted/types'] =
              resolver.resolve('runtime/interfaces')
  
          nuxt.options.alias['#redacted/utils'] = resolver.resolve(
              'runtime/utils/shared'
          )
  
          const componentsPaths = [
              resolver.resolve('runtime/components/common/global'),
          ]
  
          componentsPaths.forEach((path) => {
              addComponentsDir({
                  path,
                  global: true
              })
          })
  
          await installModule('@nuxtjs/tailwindcss', {
              // module configuration
              exposeConfig: true,
              config: {
                  content: {
                      files: [
                          resolver.resolve('./runtime/**/*.{vue,mjs,ts}'),
                          resolver.resolve('./runtime/*.{mjs,js,ts}')
                      ]
                  }
              }
          })
  
          await installModule('@nuxtjs/i18n', {
              vueI18n: resolver.resolve('./i18nconfig')
          })
  
          await installModule('@nuxtjs/device', {})
      }
  })

I also have a tsconfig file for the playground and one for the tests folder that use vitest.

Here's the main tsconfig file:


{
  "extends": "./.nuxt/tsconfig.json",
  "compilerOptions": {
    "types": ["vitest/globals"]
  },
  "exclude": [
    "dist",
    "node_modules",
    "playground",
    "test"
  ]
}

Thanks for your help !

@HugoRCD
Copy link

HugoRCD commented Jun 21, 2024

Got the exact same issue in this repository:
https://github.com/Mockline/mockline/tree/mk-90

@vernaillen
Copy link

Same error here after upgrading typescript to 5.5.2. The error went away after downgrading typescript to 5.4.5

@HugoRCD
Copy link

HugoRCD commented Jun 22, 2024

This allows the command to be run successfully, but the 'Could not map moduleDetection force
is always the same

@fornazaric
Copy link
Author

fornazaric commented Jun 24, 2024

I just tried downgrading Typescript and now i have this error:


 ERROR  VirtualCode id must be lowercase: scriptFormat              

  at verifyVirtualCode (node_modules/@volar/language-core/index.js:230:19)
  at Object.set (node_modules/@volar/language-core/index.js:127:29)
  at node_modules/@volar/typescript/lib/node/proxyCreateProgram.js:76:42
  at Object.get (node_modules/@volar/language-core/index.js:42:17)
  at options.host.getSourceFile (node_modules/@volar/typescript/lib/node/proxyCreateProgram.js:113:59)
  at findSourceFileWorker (node_modules/typescript/lib/typescript.js:122267:25)
  at findSourceFile (node_modules/typescript/lib/typescript.js:122186:22)
  at node_modules/typescript/lib/typescript.js:122135:24
  at getSourceFileFromReferenceWorker (node_modules/typescript/lib/typescript.js:122104:28)
  at processSourceFile (node_modules/typescript/lib/typescript.js:122133:7)



 ERROR  VirtualCode id must be lowercase: scriptFormat 

@navanjr
Copy link

navanjr commented Jun 24, 2024

I get the same

Could not map moduleDetection force

When following the quick start steps: https://nuxt.com/docs/guide/going-further/modules#quick-start

btw: downgrading to @nuxt/module-builder:^0.5.0 works

@danielroe
Copy link
Member

This is now resolved in mkdist and should be fixed with a lockfile refresh.

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

No branches or pull requests

5 participants