xuri / excelize-wasm

A WebAssembly build of the Go Excelize library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
190 stars 33 forks source link

Does not run on Node 20+ #22

Closed woess closed 5 months ago

woess commented 5 months ago

Description

excelize-wasm 0.0.4 does not run on Node 20 or later due to following code trying to patch global.crypto if window is undefined: https://github.com/xuri/excelize-wasm/blob/1bcf40777dce377549d407a36bbaf2c9c7098320/src/index.js#L1-L14:

require('excelize-wasm'); throws to the following error:

TypeError: Cannot set property crypto of #<Object> which has only a getter
    at Module.<anonymous> (…/node_modules/excelize-wasm/main.cjs:1:46588)

because global.crypto is now a getter without a setter.

Node already has crypto.getRandomValues and performance.now available by default, so this patching is not even needed, i.e. should be skipped if these properties already exist.

Output of node -v: v20.11.1

Excelize version or commit ID: v0.0.4

xuri commented 5 months ago

Thanks for your issue. This problem has been resolved, please upgrade to the main branch code, and this path will be released in the next version.