fab-spec / fab

💎 FAB project specification & monorepo
https://fab.dev
MIT License
579 stars 37 forks source link

Next JS npm run build:fab not working #289

Open marishprabhu opened 3 years ago

marishprabhu commented 3 years ago

Node version : v12.18.2 NPM version : 6.14.5

Steps to reproduce:

mkdir nextfab npx create-next-app cd nextfab npm run dev npx fab init npm run fab:build

0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'fab:build' 1 verbose cli ] 2 info using npm@6.14.5 3 info using node@v12.18.2 4 verbose run-script [ 'prefab:build', 'fab:build', 'postfab:build' ] 5 info lifecycle nextfab@0.1.0~prefab:build: nextfab@0.1.0 6 info lifecycle nextfab@0.1.0~fab:build: nextfab@0.1.0 7 verbose lifecycle nextfab@0.1.0~fab:build: unsafe-perm in lifecycle true 9 verbose lifecycle nextfab@0.1.0~fab:build: CWD: D:\frontend\next_fab\nextfab 10 silly lifecycle nextfab@0.1.0~fab:build: Args: [ '/d /s /c', 'fab build' ] 11 silly lifecycle nextfab@0.1.0~fab:build: Returned: code: 1 signal: null 12 info lifecycle nextfab@0.1.0~fab:build: Failed to exec fab:build script 13 verbose stack Error: nextfab@0.1.0 fab:build: fab build 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:315:20) 13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:315:20) 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 14 verbose pkgid nextfab@0.1.0 15 verbose cwd D:\frontend\next_fab\nextfab 16 verbose Windows_NT 10.0.17763 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "fab:build" 18 verbose node v12.18.2 19 verbose npm v6.14.5 20 error code ELIFECYCLE 21 error errno 1 22 error nextfab@0.1.0 fab:build: fab build 22 error Exit status 1 23 error Failed at the nextfab@0.1.0 fab:build script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

geelen commented 3 years ago

Weird, I can't see what might be going wrong, it seems like it's just... failing?

fab:build: Returned: code: 1 signal: null

That seems to be the only FAB-related line from the logs...

Can you try running npx fab build directly (after building Next with npm build separately) and see what happens?

Also, what environment are you using? Windows with Cygwin or Powershell or anything? I haven't really tested it outside of WSL on my windows machine so I'm not sure whether something simple is misconfigured to work there...

marishprabhu commented 3 years ago

Following the above mentioned steps also throws the same error. For more information I am working on windows 10 machine running steps in command prompt not using Windows with Cygwin or Powershell or anything. I followed the video given in the index page of fab.dev.

Error: "final_responder" does not exist in the hypothetical file system! Code: PLUGIN_ERROR

awthwathje commented 3 years ago

Same here. Works in Linux, consistently fails in Windows: Error: "final_responder" does not exist in the hypothetical file system!.

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'run',
0 verbose cli   'fab:build'
0 verbose cli ]
1 info using npm@7.0.8
2 info using node@v15.2.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:D:\Dev\Projects\next-fab\.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:C:\Users\someuser\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\someuser\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 8ms
19 verbose npm-session 4f487f09484cb3c7
20 timing npm:load Completed in 15ms
21 timing command:run-script Completed in 3835ms
22 verbose stack Error: command failed
22 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
22 verbose stack     at ChildProcess.emit (node:events:329:20)
22 verbose stack     at maybeClose (node:internal/child_process:1055:16)
22 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5)
23 verbose pkgid next-fab@0.1.0
24 verbose cwd D:\Dev\Projects\next-fab
25 verbose Windows_NT 10.0.19041
26 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "fab:build"
27 verbose node v15.2.0
28 verbose npm  v7.0.8
29 error code 1
30 error path D:\Dev\Projects\next-fab
31 error command failed
32 error command C:\Windows\system32\cmd.exe /d /s /c "fab build"
33 verbose exit 1

Also: npm run build && npm run fab:build will never work in Windows PowerShell.

meotimdihia commented 3 years ago

These are errors that I got on windows 10. Fab@1.0-rc8

$ npm run fab:build

> test-fab@1.0.0 fab:build C:\sources\test-fab
> 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 C:\sources\test-fab\.next
[…/input-nextjs] Finding all static HTML pages…
[…/input-nextjs] ✔ Found 32 static html pages.
[…/input-nextjs] Reusing NextJS renderer cache .fab\.cache\generated-nextjs-renderers.4f578d4.js
Build failed.
null
./.fab/.cache/generated-nextjs-renderers.4f578d4.js
Module not found: Error: Can't resolve 'console' in 'C:\sources\test-fab\.fab\.cache'
resolve 'console' in 'C:\sources\test-fab\.fab\.cache'
  Parsed request is a module
  using description file: C:\sources\test-fab\package.json (relative path: ./.fab/.cache)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      C:\sources\test-fab\.fab\.cache\node_modules doesn't exist or is not a directory
      C:\sources\test-fab\.fab\node_modules doesn't exist or is not a directory
      C:\sources\node_modules doesn't exist or is not a directory
      C:\node_modules doesn't exist or is not a directory
      looking for modules in C:\sources\test-fab\node_modules
        using description file: C:\sources\test-fab\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: C:\sources\test-fab\package.json (relative path: ./node_modules/console)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\console doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\console.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\console.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\console.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\console.json doesn't exist
            as directory
              C:\sources\test-fab\node_modules\console doesn't exist
[C:\sources\test-fab\.fab\.cache\node_modules]
[C:\sources\test-fab\.fab\node_modules]
[C:\sources\node_modules]
[C:\node_modules]
[C:\sources\test-fab\node_modules\console]
[C:\sources\test-fab\node_modules\console.wasm]
[C:\sources\test-fab\node_modules\console.mjs]
[C:\sources\test-fab\node_modules\console.js]
[C:\sources\test-fab\node_modules\console.json]
 @ ./.fab/.cache/generated-nextjs-renderers.4f578d4.js 30195:21-39
 @ ./.fab/.cache/entry-point.js,./.fab/.cache/generated-nextjs-renderers.4f578d4.js
Module not found: Error: Can't resolve 'tls' in 'C:\sources\test-fab\.fab\.cache'
resolve 'tls' in 'C:\sources\test-fab\.fab\.cache'
  Parsed request is a module
  using description file: C:\sources\test-fab\package.json (relative path: ./.fab/.cache)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      C:\sources\test-fab\.fab\.cache\node_modules doesn't exist or is not a directory
      C:\sources\test-fab\.fab\node_modules doesn't exist or is not a directory
      C:\sources\node_modules doesn't exist or is not a directory
      C:\node_modules doesn't exist or is not a directory
      looking for modules in C:\sources\test-fab\node_modules
        using description file: C:\sources\test-fab\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: C:\sources\test-fab\package.json (relative path: ./node_modules/tls)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\tls doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\tls.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\tls.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\tls.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              C:\sources\test-fab\node_modules\tls.json doesn't exist
            as directory
              C:\sources\test-fab\node_modules\tls doesn't exist
[C:\sources\test-fab\.fab\.cache\node_modules]
[C:\sources\test-fab\.fab\node_modules]
[C:\sources\node_modules]
[C:\node_modules]
[C:\sources\test-fab\node_modules\tls]
[C:\sources\test-fab\node_modules\tls.wasm]
[C:\sources\test-fab\node_modules\tls.mjs]
[C:\sources\test-fab\node_modules\tls.js]
[C:\sources\test-fab\node_modules\tls.json]
 @ ./.fab/.cache/generated-nextjs-renderers.4f578d4.js 58910:21-35
 @ ./.fab/.cache/entry-point.js
    TypeError: Cannot read property 'message' of undefined

Edit: It seems these errors still happen on ubuntu Edit: I tried to remove https://github.com/vercel/next.js/tree/canary/examples/with-sentry . Then Fab build does working.

marishprabhu commented 3 years ago

@meotimdihia Please let me know how to remove https://github.com/vercel/next.js/tree/canary/examples/with-sentry from next.js project and you managed to get the FAB build working.

meotimdihia commented 3 years ago

I don't know about how it does work after I removed sentry from next.js. But I think Fab is incompatible with some packages.

marishprabhu commented 3 years ago

Okay I got it . But I am not having idea to remove sentry from next.js.. Is there any steps to follow to remove sentry from next js and make the FAB build run. Or If you share any sample github public repo would be helpful. And I am not using Sentry in my code..

meotimdihia commented 3 years ago

Sentry is not installed with Next.js by default. If you can't build on a fresh next.js project with Fab, then it is another bug, and not relate to my case. 🙂

marishprabhu commented 3 years ago

Yes, I am not able to build using fresh next.js code with nothing added. I will recheck again with different versions of FAB and next js.