Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iconv-lite: EUC-JP, EUC-KR not recognized #76

Open
tamtranbluedragonvn opened this issue Jul 19, 2024 · 6 comments
Open

iconv-lite: EUC-JP, EUC-KR not recognized #76

tamtranbluedragonvn opened this issue Jul 19, 2024 · 6 comments

Comments

@tamtranbluedragonvn
Copy link

TypeError: Cannot read properties of undefined (reading 'prototype') at node_modules/iconv-lite/encodings/internal.js

@mkdudeja
Copy link

getting the same issue. using react with vite.
Screenshot 2024-09-14 at 4 07 44 PM

@tamtranbluedragonvn
Copy link
Author

@mkdudeja I don't remember how to fixed it. However, you can try delete node_modules folder, package-lock.json and yarn.lock

@mkdudeja
Copy link

@tamtranbluedragonvn tried everything, but no luck

@tamtranbluedragonvn
Copy link
Author

@mkdudeja You can try.

import React, { useEffect } from "react";
import { Col, Card, Button, FormSelect } from "react-bootstrap";
import { useLocale } from "../hooks/useLocale";
import { useSerialPrinter } from "../hooks/useSerialPrinter";
import { Cut, Line, Printer, Text, Row } from "react-thermal-printer";
import BaseLayout from "../components/BaseLayout";
import { RtpTableRow } from "../components/react-thermal-printer-custom/RtpTableRow";
import useSerialPorts from "../hooks/useSerialPorts";
import getStorageComport from "../utils/getStorageComport";

const ComOptions = () => {
	const { ports } = useSerialPorts();
	return (
		<>
			<option value="-1">Auto</option>
			{ports.map((port: SerialPort, index) => {
				return (
					<option key={index} value={index}>
						Port {index + 1}
					</option>
				);
			})}
		</>
	);
};
const SettingPrinterPage: React.FC = () => {
	const { t } = useLocale();
	const { printerSetting } = useSerialPrinter();
	const content = (
		<Printer type="epson" width={42} characterSet="korea" debug={true}>
			<Text bold={true}>[사업장 정보]</Text>
			<RtpTableRow
				rowData={["Col1", "Col2", "Col3", "Col4"]}
				colPercentages={[40, 25, 10, 25]}
				gap={1}
				bold={true}
			/>
			<RtpTableRow
				rowData={["ProductNameDescriptionVeryLong", "25,000", "4", "100,000"]}
				colPercentages={[40, 25, 10, 25]}
				gap={1}
				alignRights={[false, true, true, true]}
			/>
			<RtpTableRow
				rowData={["adgquiwb 31sdsjk fh32", "25,000", "4", "100,000"]}
				colPercentages={[40, 25, 10, 25]}
				gap={1}
				alignRights={[false, true, true, true]}
			/>
			<RtpTableRow
				rowData={["kk oo asd", "25,000", "4", "100,000"]}
				colPercentages={[40, 25, 10, 25]}
				gap={1}
				alignRights={[false, true, true, true]}
			/>
			<Line character="=" />
			<Row left="사업장명:" right="아마존아쿠아파크 당진" gap={2} />
			<Row left="사업장번호:" right="611-85-08304" gap={2} />
			<Row left="전화번호:" right="041-430-8299" gap={2} />
			<Row left="주소:" right={<Text>충청남도 당진시 신평면</Text>} gap={2} />
			<Row left="" right={<Text>소창길 117</Text>} gap={2} />
			<Line character="=" />
			<Text bold={true}>[가맹점정보]</Text>
			<Line character="=" />
			<Row left="가맹점명:" right="(주)코어솔루션" gap={2} />
			<Row left="사업 No:" right="628-87-03015" gap={2} />
			<Row left="전화번호:" right="1522-4030" gap={2} />
			<Row left="단말 No:" right="7498287" gap={2} />
			<Row left="주소:" right={<Text>전북특별자치도 전주시</Text>} gap={2} />
			<Row left="" right={<Text>용머리로 80, 3</Text>} gap={2} />
			<Cut />
		</Printer>
	);
	const [comPort, setComPort] = React.useState(-1);
	useEffect(() => {
		setComPort(getStorageComport());
	}, []);
	const handleOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
		localStorage.setItem("comPort", e.target.value);
		setComPort(+e.target.value);
	};
	return (
		<BaseLayout>
			{/* There is no react-bootstrap element for d-flex so that we can keep it as div */}
			<div className="d-flex justify-content-center p-5 fs-20 mt-5">
				<Col>
					<Card>
						<Card.Header>
							<Card.Title>
								<h3 className="mb-0">{t("Setting")}</h3>
							</Card.Title>
						</Card.Header>
						<Card.Body>
							<Col xs={12} className="s">
								<p>{t("Print setting")}</p>
							</Col>

							<Col xs={12} className="s d-flex gap-2">
								<Col xs={12} sm={4} className="s">
									{" "}
									<FormSelect onChange={handleOnChange} value={comPort}>
										<ComOptions />
									</FormSelect>
								</Col>
								<Col xs={12} sm={4} className="s">
									<Button
										className="btn btn-success"
										variant="bordered"
										color="primary"
										onClick={() => {
											printerSetting({
												printContent: content,
											});
										}}
									>
										프린트
									</Button>
								</Col>
							</Col>
						</Card.Body>
					</Card>
				</Col>
			</div>
		</BaseLayout>
	);
};

export default SettingPrinterPage;

@hijjoy
Copy link

hijjoy commented Sep 23, 2024

im getting the same issue. using react with vite.
and i tried this

yarn add buffer stream-browserify

//vite.config.ts
   resolve: {
    alias: {
      buffer: "buffer",
      stream: "stream-browserify",
    },
  },
  define: {
    "process.env": {},
  },
  build: {
    rollupOptions: {
      external: ["stream"],
    },
  },

@seokju-na
Copy link
Owner

#62 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants