简体   繁体   English

未找到模块:无法解析 Next.js - TypeScript

[英]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.

相关问题 找不到模块:无法解析 Next.js 应用程序中的“fs” - Module not found: Can't resolve 'fs' in Next.js application 找不到模块:无法解析“fs”,Next.Js - Module not found: Can't resolve 'fs', Next.Js Next.js 未找到模块:无法解析“tls” - Next.js Module not found: Can't resolve 'tls' 未找到模块:无法在 next.js 项目中解析“../styles/global.css” - Module not found: Can't resolve '../styles/global.css' in an next.js project 未找到模块:无法在 Next.js 应用程序中解析“@react-stately/collections” - Module not found: Can't resolve '@react-stately/collections' in Next.js app 如何解决Module not found: Can&#39;t resolve &#39;firebase/storage&#39; in next.js (已经完成 yarn add firebase) - how to resolve the problem Module not found: Can't resolve 'firebase/storage' in next.js (already done yarn add firebase) 找不到模块:无法使用 Next.js mysql Express React 解析“.../node_modules/destroy”中的“fs” - Module not found: Can't resolve 'fs' in '.../node_modules/destroy' using Next.js mysql Express React 使用带有 Next.js 的 Typescript 找不到具有相应类型声明的模块 - Module not found with corresponding type declarations using Typescript with Next.js 我正在尝试将 NPM package 作为插件注入到 Next.js 应用程序上,以避免出现“找不到模块:无法解析‘child_process’”错误 - I'm Trying to Inject An NPM package As A Plugin on A Next.js App to Avoid A "Module not found: Can't resolve 'child_process'" Error Typescript 找不到模块 无法解决 - Typescript Module not found Can't resolve
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM