我正在尝试锻炼为什么会出错。 尽管如果我没有在CardImage周围包裹CardWrapper,则图像将显示。
import React from 'react'
import styled, { css } from 'styled-components'
const CardWrapper = styled.div`
background-color: yellow;
border-color: 1px solid red;
position: relative;
`
const CardImage = styled.img`
height: auto;
width: 100%;
`
const Card = props => {
return (
<CardWrapper>
<CardImage src={props.data.imageUrl}/>
</CardWrapper>
)
}
export default Card;
App.js
<Card data={{imageUrl: 'https://via.placeholder.com/630x354', logoUrl: "https://via.placeholder.com/100x100", text: "test"}}/>
错误
./src/Components/Card/Card.js
Error: Cannot find module '/Users/max/test/test/test/node_modules/babel-preset-react-app/node_modules/@babel/core/lib/index.js'. Please verify that the package.json has a valid "main" entry
答案 0 :(得分:1)
看起来您需要安装Node.js软件包。在终端中,导航到项目的根目录并运行:
npm install babel-preset-react-app