export-from-json icon indicating copy to clipboard operation
export-from-json copied to clipboard

Error: require() of ES Module /Users/xiangyanxia/fuxi/zb/zhongbao/node_modules/export-from-json/dist/umd/index.js from

Open xiayanxiang opened this issue 1 year ago • 2 comments

When I use require('export-from-json'), it failed: Error: require() of ES Module /Users/xiangyanxia/fuxi/zb/zhongbao/node_modules/export-from-json/dist/umd/index.js from /Users/xiangyanxia/fuxi/zb/zhongbao/packages/manage/test/component/TaskDataSetting/parse.test.ts not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/xiangyanxia/fuxi/zb/zhongbao/node_modules/export-from-json/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). And I found that in the package.json file, has a 'type="modile"' , so that I cant use require('export-from-json').

xiayanxiang avatar Feb 05 '24 06:02 xiayanxiang

Faced the same issue

melikyants avatar Feb 15 '24 09:02 melikyants

Faced the same issue

bdyyang avatar Jun 26 '24 12:06 bdyyang