我创建了一个react应用程序,与chessground@7.16.13一起工作。
现在我正在尝试将chessground升级到8.2.1版本,但是有8个错误如下:
ERROR in ./node_modules/react-chessground/node_modules/chessground/chessground.js 1:0-30
Module not found: Error: Can't resolve './api' in 'C:\User\file\node_modules\react-chessground\node_modules\chessground'
Did you mean 'api.js'?
BREAKING CHANGE: The request './api' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
对于'./config‘、'./state’、‘./包’、'./events‘、’./呈现‘、'./svg’、'./util‘也是如此。
这是我的密码:
import { useState } from "react";
import Chessground from "react-chessground";
import "./chess.css";
import "./styles.css";
import "./theme.css";
import toDests from "./to-dests";
import { Chess } from "chess.js";
export default function Board() {
const [fen, setFen] = useState(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
);
const chess = new Chess(fen);
const turnColor = chess.turn() === "w" ? "white" : "black";
const handleMove = ( from, to ) => {
chess.move({ from, to, promotion: "q" });
setFen(chess.fen());
};
return (
<div className="justChessBoard">
<div>
<Chessground
fen={fen}
turnColor={turnColor}
onMove={handleMove}
movable={toDests(chess)}
/>
</div>
</div>
);
}
我是做错了什么还是不能一起工作?
https://stackoverflow.com/questions/72007642
复制相似问题