我创建了一个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>
);
}我是做错了什么还是不能一起工作?
发布于 2022-04-26 03:13:08
棋盘控件于2021年6月16日发布了第一个版本8.0.0-Beta1。有关更多详细信息,请参阅标签。
同时,反应棋盘控件的最后一个版本来自2018年4月18日。
通常,主要版本增量意味着至少会破坏一些API。作者(或社区)需要更新反应棋盘控制。
由于反应棋盘控制是很久以前更新的,它有可能不再被开发。但是有这个存储库的52个叉子。也许最近的一家公司确实与v8合作过。
https://stackoverflow.com/questions/72007642
复制相似问题