vite打包报错 "" is not exported

vite打包依赖报错

'getFloat16' is not exported by node_modules/@petamoriken/float16/browser/float16.js, imported by node_modules/ol/node_modules/geotiff/dist-module/geotiffimage.js
file: /iot_web/node_modules/ol/node_modules/geotiff/dist-module/geotiffimage.js:2:9
1: /** @module geotiffimage */
2: import { getFloat16 } from '@petamoriken/float16';
            ^
3: import getAttribute from 'xml-utils/get-attribute.js';
4: import findTagsByName from 'xml-utils/find-tags-by-name.js';
error during build:
Error: 'getFloat16' is not exported by node_modules/@petamoriken/float16/browser/float16.js, imported by node_modules/ol/node_modules/geotiff/dist-module/geotiffimage.js
    at error (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at Module.error (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:12412:16)
    at Module.traceVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:12771:29)
    at ModuleScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:11423:39)
    at ChildScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:6355:38)
    at ClassBodyScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:6355:38)
    at ChildScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:6355:38)
    at FunctionScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:6355:38)
    at ChildScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:6355:38)
    at BlockScope.findVariable (file:///D:/workspace/%E7%89%A9%E8%81%94%E7%BD%91%E5%B9%B3%E5%8F%B0%20%E6%96%B0/iot_web/node_modules/rollup/dist/es/shared/rollup.js:6355:38)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the internet-things-platform-web@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\node\node_cache\_logs\2023-04-19T03_07_09_424Z-debug.log

报错依赖文件:

img


img

已经安装的依赖:

img

已经尝试过其他版本,还是不能解决报错

参考自chatGPT:
这个错误可能是由于@petamoriken/float16和geotiff这两个库同时使用时,版本不兼容或者存在冲突导致的。可以尝试以下几种解决方法:

1.升级geotiff库的版本,看是否能够解决问题。可以使用npm update geotiff命令进行升级。

2.升级@petamoriken/float16库的版本,看是否能够解决问题。可以使用npm update @petamoriken/float16命令进行升级。

3.如果以上两种方法都无法解决问题,可以尝试使用npm dedupe命令对依赖关系进行优化。这个命令可以用来消除依赖树中的重复模块,以减少冲突和兼容性问题。

4.如果以上方法都无法解决问题,可以考虑更换其他库或者等待库的更新。
总之,这个问题的解决方法可能会因具体情况而异,需要根据错误提示和具体依赖关系进行分析和判断。