반응형
이 종속성을 찾을 수 없습니다(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
반응형
'sourcecode' 카테고리의 다른 글
vue js 또는 jquery를 사용하여 요소의 개체 바꾸기 (0) | 2022.08.19 |
---|---|
모든 액션 Vuex 전 콜 변환 (0) | 2022.08.19 |
파일의 미디어 타입(MIME 타입)을 취득하는 방법 (0) | 2022.08.19 |
현재 날짜와 시간을 얻는 방법 (0) | 2022.08.19 |
vue-router의 비동기 저장소 데이터에 액세스하여 beforeHook에서 사용하는 방법Enter hook? (0) | 2022.08.19 |