해결된 질문
작성
·
799
0
안녕하세요.
수업을 듣던중에 같은 방법으로 uuid 라이브러리를 다운받고 실행을 하고있는데 이런 에러가 발생을 하고 있는데
혹시 어떤 부분이 문제인지 알수있을까요..?
@types/uuid 로 삭제 설치 다시 해보고 진행해도 계속 같은 에러가 발생합니다 ㅠ
<package.json>
"dependencies": {
"@types/uuid": "^8.3.4",
"graphql-request": "^5.0.0",
"graphql-tag": "^2.12.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-query": "^3.39.2",
"react-router-dom": "^6.4.3",
"sass": "^1.56.1"
},
<handlers.ts>
import { v4 as uuid } from "uuid";
const mock_products = Array.from({ length: 20 }).map((_, i) => ({
id: uuid(),
imageUrl: `https://placeimg.com/200/150/${i + 1}`,
price: 50000,
title: `임시상품${i + 1}`,
description: `임시상세내용${i + 1}`,
createAt: new Date(1668159460287 + i * 1000 * 60 * 60 * 10).toString(),
}));
<에러 내용>
[plugin:vite:import-analysis] Failed to resolve import "uuid" from "src\mocks\handlers.ts". Does the file exist?
C:/Users/home/Desktop/배포/shop/shopping/src/mocks/handlers.ts:3:27
1 | import { graphql } from "msw";
2 | import GET_PRODUCTS from "../graphql/products";
3 | import { v4 as uuid } from "uuid";
| ^
4 | const mock_products = Array.from({ length: 20 }).map((_, i) => ({
5 | id: uuid(),
at formatError (file:///C:/Users/home/Desktop/%EB%B0%B0%ED%8F%AC/shop/shopping/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:39971:46)
at TransformContext.error (file:///C:/Users/home/Desktop/%EB%B0%B0%ED%8F%AC/shop/shopping/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:39967:19)
at normalizeUrl (file:///C:/Users/home/Desktop/%EB%B0%B0%ED%8F%AC/shop/shopping/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:36835:33)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async TransformContext.transform (file:///C:/Users/home/Desktop/%EB%B0%B0%ED%8F%AC/shop/shopping/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:36968:47)
at async Object.transform (file:///C:/Users/home/Desktop/%EB%B0%B0%ED%8F%AC/shop/shopping/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:40224:30)
at async loadAndTransform (file:///C:/Users/home/Desktop/%EB%B0%B0%ED%8F%AC/shop/shopping/node_modules/vite/dis
답변 1
2
공유해주신 package.json의 dependencies를 살펴보니
uuid 자체는 설치하지 않고 @types/uuid만 설치하신 것 같아요.
yarn add uuid
혹은
npm i uuid
해주세요 :)