Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local build failing #489

Closed
dev-geddy opened this issue Jan 25, 2023 · 4 comments
Closed

Local build failing #489

dev-geddy opened this issue Jan 25, 2023 · 4 comments

Comments

@dev-geddy
Copy link

Describe the problem

yarn build results in error:

$ npm run lint && rollup -c --environment NODE_ENV:production

> @auth0/auth0-react@2.0.0 lint
> eslint --ext=tsx ./src ./__tests__

[!] TypeError: Unknown file extension ".json" for /Users/my-path-to-project/auth0-react/package.json
    at new NodeError (node:internal/errors:371:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:87:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:102:38)
    at defaultLoad (node:internal/modules/esm/load:21:14)
    at ESMLoader.load (node:internal/modules/esm/loader:359:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:58)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:297:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:261:34)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:81:21)


error Command failed with exit code 1.

What was the expected behaviour?

I would expect build to complete without an error

Reproduction

  • checkout the latest master from auth0-react repo
  • use node v16.14
  • run yarn to install dependencies
  • run yarn build
  • see error, neither build, start or publish works, all result in same error.

Environment

  • Version of auth0-react used: 2.0.0
  • Which framework are you using, if applicable (Angular, React, etc): React
@ewanharris
Copy link
Contributor

@dev-geddy could you please try using node 16.15.0 or newer, the build process uses import assertions that look to have shipped in 16.14.0 but they were behind a flag until 16.15.0.

If you're unable to update your node version then you could also set the NODE_OPTIONS='--experimental-json-modules' environment variable to enable that feature

@dev-geddy
Copy link
Author

dev-geddy commented Jan 25, 2023

I have switched to node v16.15.1 (also tried v18), getting rollup-error:

❯ yarn build
yarn run v1.22.18
$ npm run lint && rollup -c --environment NODE_ENV:production

> @auth0/auth0-react@2.0.0 lint
> eslint --ext=tsx ./src ./__tests__

(node:74788) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
oidc-provider WARNING: Unsupported runtime. Use Node.js v18.x LTS, or a later LTS release.

src/index.tsx → dist/auth0-react.js...
[!] (plugin rpt2) RollupError: src/with-auth0.tsx:37:12 - error TS2786: 'Component' cannot be used as a JSX component.
  Its element type 'ReactElement<any, any> | Component<P, any, any> | null' is not a valid JSX element.
    Type 'Component<P, any, any>' is not assignable to type 'Element | ElementClass | null'.
      Type 'Component<P, any, any>' is not assignable to type 'ElementClass'.
        The types returned by 'render()' are incompatible between these types.
          Type 'React.ReactNode' is not assignable to type 'import("/Users/gediminas/WEB/auth0-react/node_modules/@types/react-test-renderer/node_modules/@types/react/index").ReactNode'.
            Type '{}' is not assignable to type 'ReactNode'.

37           <Component {...(props as P)} auth0={auth} />
              ~~~~~~~~~

src/index.tsx

@ewanharris
Copy link
Contributor

If you install the dependencies using npm do you see the same issue? I suspect that installing via yarn has maybe pulled in multiple versions of @types/react which are clashing, it works locally for me using npm as we have a package-lock that will ensure correct/aligned versions

@dev-geddy
Copy link
Author

I was able to npm install and compile locally by following the above. Thank you for help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants