Skip to content

Local build failing #489

Description

@dev-geddy

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

Activity

  1. ewanharris commented on Jan 25, 2023

    @ewanharris
    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

  2. dev-geddy commented on Jan 25, 2023

    @dev-geddy
    Author

    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
    
    
  3. ewanharris commented on Jan 25, 2023

    @ewanharris
    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

  4. dev-geddy commented on Jan 26, 2023

    @dev-geddy
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions