[英]Module not found: Can't resolve Next.js - TypeScript
I receive the image´s error but I don´t understand why do I get it.
我收到图像的错误,但我不明白为什么会得到它。 Also attached the directory in the second image.
还附上了第二张图片中的目录。
import Link from 'next/link';
import { useState } from 'react';
import { ProductModel } from '../models/product';
import { CardProduct } from '../components/CardProduct';
const List = () => {
let list: ProductModel[] = [ //ProductModel[] esto significa que va a ser un array de ProductModel
{
id: 1,
name: "shoes",
price: 9999,
},
];
const [products, setProducts] = useState<ProductModel[]>(list);
return (
<div>
Soy la página de Productos
{products.map((element, index) => {
return <CardProduct product={element}/>;
})}
<br/>
<Link href="/">
<a>Ir a la home</a>
</Link>
</div>
);
}
export default List;
You need to create an empty tsconfig.json
file in your root folder and then run npm as you would normally (for instance, npm run dev
).您需要在根文件夹中创建一个空的
tsconfig.json
文件,然后像往常一样运行 npm (例如, npm run dev
)。 NextJs will then populate the file with default ts config values. NextJs 将使用默认的 ts 配置值填充文件。 See here:
看这里:
https://nextjs.org/docs/basic-features/typescript https://nextjs.org/docs/basic-features/typescript
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.