click-to-component icon indicating copy to clipboard operation
click-to-component copied to clipboard

Add require exports

Open purple-force opened this issue 1 year ago • 17 comments
trafficstars

Describe the bug when require.resolve('click-to-react-component'), an error was thrown: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in xxxxx//ode_modules/click-to-react-component/package.json

To Reproduce Steps to reproduce the behavior:

  1. npm i click-to-react-component
  2. See error

Expected behavior No error.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

purple-force avatar Nov 04 '24 02:11 purple-force

exports.require need to be added in package.json

purple-force avatar Nov 04 '24 02:11 purple-force

i got the same issue

Dmaziyo avatar Nov 04 '24 02:11 Dmaziyo

i got the same issue when using ant-design-pro

mustang1988 avatar Nov 04 '24 02:11 mustang1988

i got the same issue when using ant-design-pro

You can revert the dependencies to the previously stable version (e.g., 1.0.8) as a temporary fix to start the project image

Dmaziyo avatar Nov 04 '24 02:11 Dmaziyo

i got the same issue when using ant-design-pro

hogancv avatar Nov 04 '24 02:11 hogancv

i got the same issue when using ant-design-pro

temporarily add require image

purple-force avatar Nov 04 '24 02:11 purple-force

image image 编译一直报错 过不去 应该怎么解决啊

YunHannn avatar Nov 04 '24 08:11 YunHannn

same issue here

aapelismith avatar Nov 04 '24 09:11 aapelismith

I don't think this is an error:

  1. in webpack project, it can build successfully, showing no issues with the recommended usage of this package.

  2. only having exports.import means this package strictly allows Native ESM imports only, and the following code runs correctly:

    // test.js
    
    import * as mod from 'click-to-react-component'
    
    const run = async () => {
      const mod2 = await import('click-to-react-component')
      console.log('mod: ', mod)
      // mod:  [Module: null prototype] { ClickToComponent: [Function (anonymous)] }
      console.log('mod2: ', mod2)
      // mod2:  [Module: null prototype] { ClickToComponent: [Function (anonymous)] }
    }
    
    run()
    

fz6m avatar Nov 04 '24 22:11 fz6m

i got the same issue, how to fix?

berber1016 avatar Nov 05 '24 08:11 berber1016

i got the same issue, how to fix?

add resolutions to package.json

// package.json
  "resolutions": {
    "click-to-react-component":"1.1.0"
  }

berber1016 avatar Nov 05 '24 08:11 berber1016

same issue

QKflame avatar Nov 06 '24 11:11 QKflame

添加 "click-to-react-component":"1.0.8" 就可以解决了

WindRisess avatar Nov 07 '24 04:11 WindRisess

fix with below code add in package.json

  "resolutions": {
    "click-to-react-component": "1.0.8",
  },

giscafer avatar Nov 07 '24 15:11 giscafer

Same issue, any progress?

wizardpisces avatar Nov 15 '24 02:11 wizardpisces

How to fix this problem? Has anyone fixed this problem?

zhaodengping avatar Jan 04 '25 07:01 zhaodengping

Same issue, any progress?

I want to know too!

zhaodengping avatar Jan 04 '25 07:01 zhaodengping