Issue while deploying to Now

Hello,

Recently stumbled across Frontity and have played with it and are considering using it for an upcoming project but have come across an issue when attempting to deploy a production build to Now (this is probably better aimed at their support guys).

Followed the steps outlined here (https://docs.frontity.org/installation-and-deploy/deploy-on-now) and when the project has been uploaded to Now it fails with the following error:

    Running "build" script in "package.json"
    06:57:55 PM Running "npm run build"
    06:57:55 PM > xxxx@1.0.0 build /fargate/79229e35
    06:57:55 PM > frontity build
    06:57:56 PM mode: production
    06:57:56 PM Building es5 bundle
    06:58:15 PM Building module bundle
    06:58:27 PM Building server bundle
    06:58:44 PM TypeError: Cannot read property 'fsPath' of undefined
    06:58:44 PM at Object.build (/fargate/1d2c7cfec274f2ae/.build-utils/.builder/node_modules/@frontity/now/dist/index.js:94:49)
    06:58:44 PM at <anonymous>
    06:58:44 PM worker exited with code 20 and signal null
    06:58:47 PM done

The configs are pretty basic or untouched from the initial Frontity install:
package.json

    {
      "name": "xxxx",
      "version": "1.0.0",
      "private": true,
      "description": "Frontity project",
      "keywords": [
        "frontity"
      ],
      "scripts": {
        "dev": "frontity dev",
        "build": "frontity build",
        "serve": "frontity serve"
      },
      "prettier": {},
      "dependencies": {
        "@frontity/core": "^1.2.1",
        "@frontity/html2react": "^1.1.11",
        "@frontity/mars-theme": "./packages/mars-theme",
        "@frontity/tiny-router": "^1.0.14",
        "@frontity/wp-source": "^1.3.1",
        "@frontity/yoast": "^1.1.3",
        "bootstrap": "^4.3.1",
        "frontity": "^1.3.1",
        "react-bootstrap": "^1.0.0-beta.14",
        "react-select": "^3.0.8"
      }
    }

frontity.settings.js

    const settings = {
      "name": "xxxx",
      "state": {
        "frontity": {
          "url": "xxxx",
          "title": "Test Frontity Blog",
          "description": "WordPress installation for Frontity development"
        }
      },
      "packages": [
        {
          "name": "@frontity/mars-theme",
          "state": {
            "theme": {
              "menu": [],
              "featured": {
                "showOnList": false,
                "showOnPost": false
              }
            }
          }
        },
        {
          "name": "@frontity/wp-source",
          "state": {
            "source": {
              "api": "xxxx",
              "homepage": "/home"
            }
          }
        },
        "@frontity/yoast",
        "@frontity/tiny-router",
        "@frontity/html2react"
      ]
    };

Besides the addition of some modules (Bootstrap & React Select) running the production build script locally works without issue, which is why I believe it’s probably best to post this on the Now forum.

Side note, we’re using (https://github.com/WP-API/menus-endpoints) to expose the WP menus and manually stripping out everything before the slug when it is received in Frontity. This doesn’t seem like the correct way to do this and I was hoping someone had a better solution to this.

Update: For anyone having the same issue I managed to get this deployed on Now after a bunch of reading, is the doc page up to date? My config differs greatly from what is mentioned.

Once I managed to deploy it to Now, I had an issue with assets loading (404 for everything) the additional build config fixed that “build/static/**/*”.

My updated configs can be found here: https://gist.github.com/twenty/d226825f0aa2c6ea06d686a1ea460a2d

Hello Chris, welcome to the community!

I haven’t had any issue with deploying to now recently. I do not have Bootstrap, React Select or the menus-endpoints installed on my install though.

Have you tried deploying a clean Frontity project to Now? That may help you find where the issue is once you begin adding the functionalities you are looking.

You can find the information on how to deploy at: https://docs.frontity.org/installation-and-deploy/deploy-on-now

I followed the information and had no problem.

If you go through a clean install and it still does not work, maybe someone from the @development-team may be able to help!

Hey @chris, welcome :slight_smile:

Thanks for your logs, it looks like the @frontity/now is not finding your server.js file.

Your second approach works fine (actually, our initial recommendation was pretty similar) but that config means you have to run npm run build locally before you deploy to now. With @frontity/now, the build process happens on Now.

I’d love to be able to debug your case. Is there a way you can upload your project in a private GitHub repository (and remove any sensitive data) and share that with me so I can take a look and try to fix it?


We are about to explore the integration of that plugin with Frontity. @SantosGuillamot started a topic to discuss the design the other day: Handlers for non-URL data

Could you please join that topic and add information about how are you currently approaching this and what are your specific needs and use case?

1 Like

Thanks @luisherranz.

I see, short of the build only occurring before upload to Now it shouldn’t really matter though right? I’ll try to put together a private repo for you to take a look at and will PM you a link.

I’ll have a read through that thread and add my thoughts, though my requirements are super basic (display a menu with children)

Awesome. Thank you.

That’s right, but it’s safer if the build happens in the cloud.

Thanks!

I just bumped into the same problem today while doing a deploy and the problem was not with the builder itself, but with my Frontity project, which was not working properly.

I was able to solve the problem in my local environment with npx frontity dev and then redeploy with success.

I’ve added a card to our roadmap to improve the error messages of frontity build.