1
votes

I created a project using @vue/cli@4.5.11 (Babel, TS< Router, Vuex, CSS Pre-processors, Linter/formatter)

When I do

npm run serve

it says

These dependencies were not found:

  • src/config/GlobalConfig in ./src/store/user.ts

I am importing it like so:

import { GlobalAxios } from 'src/config/GlobalConfig';

and when I change it to /src/config/GlobalConfig

i get the following type error:

Cannot find module '/src/config/GlobalConfig' or its corresponding type declarations.

What should I do to properly use the file in the store?

1

1 Answers

5
votes

You should use a relative path (and maybe the file extension depending the project configuration)

Maybe:

import { GlobalAxios } from '../config/GlobalConfig'

Or:

import { GlobalAxios } from '../config/GlobalConfig.js' // .ts ?

Or (if webpack alias is configured):

import { GlobalAxios } from '@/config/GlobalConfig.js' // .ts ?