api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
481 stars 130 forks source link

export 'HydraAdmin' (imported as 'HydraAdmin') was not found in '@api-platform/admin' (module has no exports) #468

Closed brave-coder9 closed 2 years ago

brave-coder9 commented 2 years ago

API Platform version(s) affected: 3.3.3

Description

import { HydraAdmin } from '@api-platform/admin';

function App() {
  return (
    <div className="App">
      <HydraAdmin entrypoint="https://demo.api-platform.com" />
    </div>
  );
}

export default App;

I got this error:

Compiled with problems:X

ERROR in ./src/App.js 10:35-45

export 'HydraAdmin' (imported as 'HydraAdmin') was not found in '@api-platform/admin' (module has no exports)

ERROR in ./node_modules/@api-platform/admin/lib/esm/index.js 1:0-42

Module not found: Error: Can't resolve './AdminGuesser' in 'E:\Works\CODA.TECH\test_api_platform_admin\node_modules\@api-platform\admin\lib\esm'
Did you mean 'AdminGuesser.js'?
BREAKING CHANGE: The request './AdminGuesser' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

How to reproduce

> create-react-app my_app
> yarn add @api-platform/admin
> yarn start

Additional Context
dependencies in my package.json file:

  "dependencies": {
    "@api-platform/admin": "^3.3.3",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
alanpoulain commented 2 years ago

It seems using fully specified imports (with extensions) is needed when the package is using "type": "module". I'll do it as soon as possible.

brave-coder9 commented 2 years ago

I removed "type": "module" line in the package.json and removed node_modules/.cache Then it's working. Thanks @alanpoulain

alanpoulain commented 2 years ago

Changed in 3.3.4.