question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to use imports in nuxt.config.ts via paths ?

See original GitHub issue

Environment

Nuxi 3.0.0-rc.10 14:35:32 RootDir: /home/workspace/app/packages/app/web 14:35:33 Nuxt project info: 14:35:33


  • Operating System: Linux
  • Node Version: v18.9.1
  • Nuxt Version: 3.0.0-rc.10
  • Nitro Version: 0.5.3
  • Package Manager: npm@8.19.1
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

import { createBackendConfig } from '@mypath/common-api/config/backendConfig' in your nuxt.config.ts

Describe the bug

Will result in:

ERROR Cannot start nuxt: Cannot find module '@mypath/common-api/config/backendConfig'

Which is obvious because, it doesn’t know @mypath in the context of nuxt.config.ts

In Vite I can define this for vite.config.ts in tsconfig.node.json because this tsconfig is responsible for the vite.config.ts due to "include": ["vite.config.ts", "./vite.ts"],

How do I do in nuxt environment for nuxt.config.ts ?

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Nov 1, 2022

You need to fetch from a full URL. Fetching from /api/test only works within Nuxt; elsewhere, you need to use a URL like https://path.to/my/backend/api/test.

0reactions
robmontesinoscommented, Nov 1, 2022

@danielroe Duh!! You da man Dan - thanks so much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt configuration file
This default configuration can be overwritten with the nuxt.config.js file. ... You can customize the path by using --dotenv <file> or disable entirely...
Read more >
Now to make path aliases of imports visible in nuxt.config.ts?
In this question, I don't talk about NuxtConfig.alias property which usually looks like: const Config: NuxtConfig = { alias: ...
Read more >
How to auto import Components in Source Content folder?
I tried this in nuxt.config.ts : (It doesn't work). import ... make sure to exclude it from component resolution via compilerOptions.
Read more >
Nuxt Configuration Reference
Build your next Vue.js application with confidence using Nuxt. ... import fs from 'node:fs' import path from 'node:path' export default { hooks: {...
Read more >
@nuxt/bridge-edge - npm
You can use static import , dynamic import() and export default instead. Using TypeScript by renaming to nuxt.config.ts is also possible and recommended....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found