Skip to content

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

@xiayanxiang

Description

@xiayanxiang

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').

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions