sourcecode

이 종속성을 찾을 수 없습니다(TypeScript, Vue).

copyscript 2022. 8. 19. 21:02
반응형

이 종속성을 찾을 수 없습니다(TypeScript, Vue).

TS와 Vue는 처음입니다.

vue-cli-service serve를 실행하려고 할 때 다음 오류가 표시됩니다.

This dependency was not found:

  * @store in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/ts-loader??ref--12-1!./node_modules/vue-loader/lib??vue-loader-opt
ions!./src/components/HelloWorld.vue?vue&type=script&lang=ts&

To install it, you can run: npm install --save @store

./src/components/HelloWorld.vue에서는 다음과 같이 입력합니다.

import { RootState, storeBuilder, CustomerStore } from '@store';

tsconfig.json에서는 다음과 같이 입력합니다.

"baseUrl": "./src",
"paths": {
  "@/*": ["src/*"],
  "store": ["./store/index.ts"], 

그러나 Import를 following으로 변경하면 오류가 사라집니다.

import { RootState, storeBuilder, CustomerStore } from './../store';

추가 설정 또는 패키지가 필요합니까?내 스택:

- vue 3.0.1
- tsc 3.0.3
'@store';

그래야 한다

'@/store';

해결 방법을 찾았습니다...@store'를 통해 Import할 수 있습니다.

vue.config.js를 편집하고 다음을 추가해야 했습니다.

const path = require('path');
const ROOT = path.resolve(__dirname);

function root(args) {
  args = Array.prototype.slice.call(arguments, 0);
  return path.join.apply(path, [ROOT].concat(args));
}

module.exports = {
      configureWebpack: config => {
        config.resolve = {
          extensions: ['.js', '.ts'],
          alias: {
            '@store': root('src/store/index.ts'),
          },
        };
      }
    }

언급URL : https://stackoverflow.com/questions/52252654/this-dependency-was-not-found-typescript-vue

반응형