Within my Nuxt project directory, there exists a specific folder named modules
which houses my customized modules. For this illustration, it includes the modules foo
and bar
. The inclusion of foo
in the nuxt.config.js
file appears as follows:
// nuxt.config.js
...
modules: [
...
"~/modules/foo"
],
...
It is important to note that bar
has not been added as a module.
However, when attempting to import bar
into foo
:
// foo/index.ts
import { bar } from '~/modules/bar';
export default function fooModule() {
console.log(bar)
}
// bar/index.ts
const bar = 1
export { bar };
export default function barModule() {}
An error message stating Nuxt Fatal Error
,
Error: Cannot find module '~/modules/bar'
is encountered.
Even after adding "~/modules/bar"
to modules
within nuxt.config.js
, there seems to be no change in outcome.
Any suggestions on how to resolve this issue?