我一直在尝试使用带有create-react-app应用程序的NPM打包程序包,并且遇到了各种各样的问题。我要使用的最新版本是'binpack-2d'(https://github.com/karevn/binpack-2d)。我正在按照文档中的说明使用它,但是却收到了这个奇怪的错误
./node_modules/binpack-2d/lib/index.js
Module not found: Can't resolve 'array.prototype.find' in '/Users/cerulean/Documents/Projects/sandbox/node_modules/binpack-2d/lib'
我正在按如下方式使用它
import binpack from 'binpack-2d'
const maxWidth = 30
const maxHeight = 20
const container = {width: maxWidth, height: maxHeight}
export default (menu,allData) => {
const blocks = []
if (menu < 0 || menu > allData.length-1) return []
const items = allData[menu].items
for (let i = 0; i <items.length ; i++) {
const wurst = items[i]
for (let j = 1; j <= wurst.Quantity ; j++) {
blocks.push({name:wurst.Name,w:wurst.Width,h:wurst.Length})
}
}
if (! blocks) return []
blocks.sort((a,b) => (b.h < a.h));
const result = binpack(container, blocks)
我要去哪里错了?任何建议,不胜感激!