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

Type error with fab build #258

Closed
Rashmi-278 opened this issue Sep 30, 2020 · 3 comments
Closed

Type error with fab build #258

Rashmi-278 opened this issue Sep 30, 2020 · 3 comments

Comments

@Rashmi-278
Copy link

Rashmi-278 commented Sep 30, 2020

While deploying a simple next.js app which implements oauth
next build is succesful but throws the exact same warnings as here
after this the fab build is unsucessful

`npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1601469388532-0.88403953
94907312/node but npm is using /opt/bitnami/node/bin/node itself. Use the `--scripts-prepe
nd-node-path` option to include the path for the node binary npm was executed with.

> just-auth@0.1.0 fab:build /home/bitnami/myapps/just-auth
> fab build

       [Builder]  fab build 
       [Builder] Reading plugins from config.
       [Builder] Found the following build-time plugins:
                   @fab/input-nextjs
                   @fab/plugin-render-html
                   @fab/plugin-rewire-assets
       [Builder] and the following runtime plugins:
                   node_modules/@fab/input-nextjs/runtime.js
                   node_modules/@fab/plugin-render-html/runtime.js
                   node_modules/@fab/plugin-rewire-assets/runtime.js
       [Builder] Proceeding with build phase.
       [Builder] Building @fab/input-nextjs:
[@fab/input-ne…] Reading files from /home/bitnami/myapps/just-auth/.next
[…/input-nextjs] Finding all static HTML pages…
[…/input-nextjs] ✔ Found 3 static html pages.
[…/input-nextjs] Finding all dynamic NextJS entry points
[…/input-nextjs] Found 3 dynamic pages.
[…/input-nextjs] ✔ Wrote /home/bitnami/myapps/just-auth/.fab/.cache/generated-nextjs-rende
rers.3f96fd6.js
Build failed.
null
./.fab/.cache/generated-nextjs-renderers.3f96fd6.js
Module not found: Error: Can't resolve 'child_process' in '/home/bitnami/myapps/just-auth/
.fab/.cache'
resolve 'child_process' in '/home/bitnami/myapps/just-auth/.fab/.cache'
  Parsed request is a module
  using description file: /home/bitnami/myapps/just-auth/package.json (relative path: ./.f
ab/.cache)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /home/bitnami/myapps/just-auth/.fab/.cache/node_modules doesn't exist or is not a di
rectory
      /home/bitnami/myapps/just-auth/.fab/node_modules doesn't exist or is not a directory
      /home/bitnami/myapps/node_modules doesn't exist or is not a directory
      /home/bitnami/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      looking for modules in /home/bitnami/myapps/just-auth/node_modules
        using description file: /home/bitnami/myapps/just-auth/package.json (relative path
: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /node_modules
        using description file: /package.json (relative path: .node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /home/bitnami/myapps/just-auth/package.json (relative pa
th: ./node_modules/child_process)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /package.json (relative path: .node_modules/child_proces
s)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/child_process doesn't exist
            .wasm
.wasm
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/child_process.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/child_process.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/child_process.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/child_process.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/child_process.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/child_process.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/child_process.json doesn't exist
              /node_modules/child_process.json doesn't exist
            as directory
              /home/bitnami/myapps/just-auth/node_modules/child_process doesn't exist
            as directory
              /node_modules/child_process
/node_modules/child_process doesn't exist
[/home/bitnami/myapps/just-auth/.fab/.cache/node_modules]
[/home/bitnami/myapps/just-auth/.fab/node_modules]
[/home/bitnami/myapps/node_modules]
[/home/bitnami/node_modules]
[/home/node_modules]
[/home/bitnami/myapps/just-auth/node_modules/child_process]
[/node_modules/child_process]
[/home/bitnami/myapps/just-auth/node_modules/child_process.wasm]
[/node_modules/child_process.wasm]
[/home/bitnami/myapps/just-auth/node_modules/child_process.mjs]
[/node_modules/child_process.mjs]
[/home/bitnami/myapps/just-auth/node_modules/child_process.js]
[/node_modules/child_process.js]
[/home/bitnami/myapps/just-auth/node_modules/child_process.json]
[/node_modules/child_process.json]
 @ ./.fab/.cache/generated-nextjs-renderers.3f96fd6.js 75680:21-45
 @ ./.fab/.cache/entry-point.js,./.fab/.cache/generated-nextjs-renderers.3f96fd6.js
Module not found: Error: Can't resolve 'dns' in '/home/bitnami/myapps/just-auth/.fab/.cach
e'
resolve 'dns' in '/home/bitnami/myapps/just-auth/.fab/.cache'
  Parsed request is a module
  using description file: /home/bitnami/myapps/just-auth/package.json (relative path: ./.f
ab/.cache)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /home/bitnami/myapps/just-auth/.fab/.cache/node_modules doesn't exist or is not a di
rectory
      /home/bitnami/myapps/just-auth/.fab/node_modules doesn't exist or is not a directory
      /home/bitnami/myapps/node_modules doesn't exist or is not a directory
/home/bitnami/myapps/node_modules doesn't exist or is not a directory
      /home/bitnami/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      looking for modules in /home/bitnami/myapps/just-auth/node_modules
        using description file: /home/bitnami/myapps/just-auth/package.json (relative path
: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /node_modules
        using description file: /package.json (relative path: .node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /home/bitnami/myapps/just-auth/package.json (relative pa
th: ./node_modules/dns)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /package.json (relative path: .node_modules/dns)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/dns doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/dns doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/dns.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/dns.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/dns.mjs doesn't exist
           .js
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/dns.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/dns.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/dns.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/dns.json doesn't exist
              /node_modules/dns.json doesn't exist
            as directory
              /home/bitnami/myapps/just-auth/node_modules/dns doesn't exist
            as directory
              /node_modules/dns doesn't exist
[/home/bitnami/myapps/just-auth/.fab/.cache/node_modules]
[/home/bitnami/myapps/just-auth/.fab/node_modules]
[/home/bitnami/myapps/node_modules]
[/home/bitnami/node_modules]
[/home/node_modules]
[/home/bitnami/myapps/just-auth/node_modules/dns]
[/node_modules/dns]
[/home/bitnami/myapps/just-auth/node_modules/dns.wasm]
[/node_modules/dns.wasm]
[/home/bitnami/myapps/just-auth/node_modules/dns.mjs]
[/node_modules/dns.mjs]
[/home/bitnami/myapps/just-auth/node_modules/dns.js]
[/node_modules/dns.js]
[/home/bitnami/myapps/just-auth/node_modules/dns.json]
[/node_modules/dns.json]
 @ ./.fab/.cache/generated-nextjs-renderers.3f96fd6.js 73229:21-35
 @ ./.fab/.cache/entry-point.js,./.fab/.cache/generated-nextjs-renderers.3f96fd6.js
Module not found: Error: Can't resolve 'module' in '/home/bitnami/myapps/just-auth/.fab/.c
ache'
resolve 'module' in '/home/bitnami/myapps/just-auth/.fab/.cache'
  Parsed request is a module
  using description file: /home/bitnami/myapps/just-auth/package.json (relative path: ./.f
ab/.cache)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /home/bitnami/myapps/just-auth/.fab/.cache/node_modules doesn't exist or is not a di
rectory
      /home/bitnami/myapps/just-auth/.fab/node_modules doesn't exist or is not a directory
      /home/bitnami/myapps/node_modules doesn't exist or is not a directory
      /home/bitnami/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      looking for modules in /home/bitnami/myapps/just-auth/node_modules
        using description file: /home/bitnami/myapps/just-auth/package.json (relative path
: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /node_modules
        using description file: /package.json (relative path: .node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /home/bitnami/myapps/just-auth/package.json (relative pa
th: ./node_modules/module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /package.json (relative path: .node_modules/module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/module doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/module doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/module.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/module.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/module.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/module.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/module.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/module.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/module.json doesn't exist
              /node_modules/module.json doesn't exist
            as directory
              /home/bitnami/myapps/just-auth/node_modules/module doesn't exist
           as directory
              /node_modules/module doesn't exist
[/home/bitnami/myapps/just-auth/.fab/.cache/node_modules]
[/home/bitnami/myapps/just-auth/.fab/node_modules]
[/home/bitnami/myapps/node_modules]
[/home/bitnami/node_modules]
[/home/node_modules]
[/home/bitnami/myapps/just-auth/node_modules/module]
[/node_modules/module]
[/home/bitnami/myapps/just-auth/node_modules/module.wasm]
[/node_modules/module.wasm]
[/home/bitnami/myapps/just-auth/node_modules/module.mjs]
[/node_modules/module.mjs]
[/home/bitnami/myapps/just-auth/node_modules/module.js]
[/node_modules/module.js]
[/home/bitnami/myapps/just-auth/node_modules/module.json]
[/node_modules/module.json]
 @ ./.fab/.cache/generated-nextjs-renderers.3f96fd6.js 126858:21-38
 @ ./.fab/.cache/entry-point.js,./.fab/.cache/generated-nextjs-renderers.3f96fd6.js
Module not found: Error: Can't resolve 'tls' in '/home/bitnami/myapps/just-auth/.fab/.cach
e'
resolve 'tls' in '/home/bitnami/myapps/just-auth/.fab/.cache'
  Parsed request is a module
  using description file: /home/bitnami/myapps/just-auth/package.json (relative path: ./.f
ab/.cache)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /home/bitnami/myapps/just-auth/.fab/.cache/node_modules doesn't exist or is not a di
rectory
      /home/bitnami/myapps/just-auth/.fab/node_modules doesn't exist or is not a directory
      /home/bitnami/myapps/node_modules doesn't exist or is not a directory
    /home/bitnami/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      looking for modules in /home/bitnami/myapps/just-auth/node_modules
        using description file: /home/bitnami/myapps/just-auth/package.json (relative path
: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /node_modules
        using description file: /package.json (relative path: .node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /home/bitnami/myapps/just-auth/package.json (relative pa
th: ./node_modules/tls)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /package.json (relative path: .node_modules/tls)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/tls doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/tls doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/tls.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/tls.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/tls.mjs doesn't exist
            .js
 Field 'browser' doesn't contain a valid alias configuration
              /node_modules/tls.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/tls.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /node_modules/tls.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /home/bitnami/myapps/just-auth/node_modules/tls.json doesn't exist
              /node_modules/tls.json doesn't exist
            as directory
              /home/bitnami/myapps/just-auth/node_modules/tls doesn't exist
            as directory
              /node_modules/tls doesn't exist
[/home/bitnami/myapps/just-auth/.fab/.cache/node_modules]
[/home/bitnami/myapps/just-auth/.fab/node_modules]
[/home/bitnami/myapps/node_modules]
[/home/bitnami/node_modules]
[/home/node_modules]
[/home/bitnami/myapps/just-auth/node_modules/tls]
[/node_modules/tls]
[/home/bitnami/myapps/just-auth/node_modules/tls.wasm]
[/node_modules/tls.wasm]
[/home/bitnami/myapps/just-auth/node_modules/tls.mjs]
[/node_modules/tls.mjs]
[/home/bitnami/myapps/just-auth/node_modules/tls.js]
[/node_modules/tls.js]
[/home/bitnami/myapps/just-auth/node_modules/tls.json]
[/node_modules/tls.js]
[/home/bitnami/myapps/just-auth/node_modules/tls.json]
[/node_modules/tls.json]
 @ ./.fab/.cache/generated-nextjs-renderers.3f96fd6.js 124668:21-35
 @ ./.fab/.cache/entry-point.js
    TypeError: Cannot read property 'message' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! just-auth@0.1.0 fab:build: `fab build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the just-auth@0.1.0 fab:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging outpu
t above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-30T12_37_48_440Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
@geelen
Copy link
Contributor

geelen commented Sep 30, 2020

Hmm, ok, it looks like you might have incompatible dependencies in that project.

I see four missing modules, child_process, dns, module and tls. This is usually due to an intermediate dependency that has a hard dependency on something NodeJS-y. It might be able to be worked around, it depends on what it is. From a quick glance at your blog post, something related to next-auth.

The debugging process is pretty straightforward if a little tedious:

  • Comment out any dependency you're worried about, see if fab build passes. Best way to do this is to comment out the first half of your import statements, then half of those, etc (i.e binary search is much quicker than line-by-lin).
  • Once you know exactly which top-level dependency causes the build failure, go into node_modules/<dependency>/index.js and start commenting out imports there too. Again, use binary search to divide and conquer. Note: you're just trying to get the code to webpack, not run, so you don't need to worry about breaking stuff beyond syntax errors.
  • Keep following the thread until you eventually find a dependency on something low-ish-level like request, which has a hard dependency on a bunch of Node in-built packages (like child_process/tls).

Once you've found that, we have options:

  • We can either stub out the Node libs if that makes sense
  • Or, we could stub out the low-ish level library with a API-compatible one that backs onto the Fetch API, say.
  • Alternatively, it might be so deeply connected to the Node deps that you can't stub it, and you'll just not be able to use that library with FABs, sorry. Then it's a matter of finding an equivalent package that is compatible, or another way of achieving the same things.

Hope this helps!

@Rashmi-278
Copy link
Author

Rashmi-278 commented Oct 1, 2020

@geelen
Thank you for the help !

After digging into it ,
I found there's a hard dependency on deprecated plugin
Hawk
https://www.npmjs.com/package/hawk

Also next-auth package is not compatible with cloudflare workers
That's one issue with the package.

nextauthjs/next-auth#725 (comment)

As next-auth package isn't compatible with CFW
Maybe that's why fab build is failing
And also due to dependencies on deprecated packages.

Fab build is successful without the next-auth package.

@geelen
Copy link
Contributor

geelen commented Oct 12, 2020

Ah, that's a shame. Glad you were able to track it down and can live without next-auth.

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