farmOS Field Kit wont build

Hi all - I am new to FarmOS and trying to build Field Kit. I have cloned the repo https://github.com/farmOS/field-kit (develop branch), ran npm install and npm start. I get the error below as the page loads.

client.ts:22 [vite] connecting…
client.ts:58 [vite] connected.
xhr.js?v=e552aff1:26 Uncaught ReferenceError: Cannot access ‘default’ before initialization
at (xhr.js?v=e552aff1:26:46)
at __require (xhr.js?v=e552aff1:3:50)
at xhr.js?v=e552aff1:159:16
main.js:2 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
at main.js:2:229005
(anonymous) @ main.js:2

My machine spec

  • Windows 11 Pro
  • node v16.16.0

Any ideas what I am doing wrong?

Thank you.

1 Like

Hi @Dhliwayo, welcome to the farmOS forum!

I’m just getting caught up after some extended travel, so I won’t have a chance to look at this more closely until late tomorrow at the soonest, but at a glance, I suspect this is either an error with the connection to your local farmOS development server, which is required for local testing.

If you’re willing to share, I’d be love to hear your interest in building from source. Are you just looking to self-host Field Kit, or looking to modify/extend its behavior?

Thanks for the welcome and also thank you for the great product. I am looking to self-host Field Kit with the possibility to modify its behavior if required (once I understand how its running). I currently have a trial FarmOS server running on Farmier. Do I need to point Field Kit to this server before starting it, if so, could you please point me to part of the code where this should done? Thanks.

1 Like

Hi again @Dhliwayo, and sorry for the longer-than-expected delay.

For Field Kit development, I would suggest connecting to a farmOS server on the same development machine. The Field Kit dev server, which starts up at localhost:8080 when you run the npm start command, is intended to run alongside a local farmOS dev server running independently at localhost:80. There are instructions for setting up a farmOS development server here:

Let us know if you have any other questions!

Great to hear you’re interested in developing with Field Kit! Like farmOS itself, Field Kit is intended to be a modular system for adding customized extensions to the overall application. We’re calling these “field modules”, and once we reach a beta release I should have full documentation for how to get setup developing your own field modules.

The unique aspect of these field modules is that they are designed to be hosted on your farmOS server, not on the Field Kit host, with the intention that this will eliminate the need for separate Field Kit hosting. You and everyone on your farm can still use Field Kit from https://farmos.app, with all your custom modules, while other farms who also connect to https://farmos.app can have their own, totally different set of modules, just by virtue of logging in to a different farmOS server. That way, all configuration can be done by your farmOS administrator in one place, and all updates and extensions will be sent out to Field Kit over the wire. Field Kit, in that sense, is just an application shell, which provides a single, offline-first, client-side database and shared networking utilities. That way module developers can focus more on designing the user interface and experience, and not get bogged down in the plumbing, like connecting to differently configured servers and reconciling concurrent changes to both local data and data from the server.

These developments have been very close to complete for a while now, but unfortunately other life stuff earlier this spring made it difficult for me to get the last few pieces out the door for the field module API (along with its documentation), though I’m finally getting back to dedicated work on this front.

1 Like

Hi again @jgaehring

I have kind of given up on self-hosting both Field Kit and FarmOS for development for now…
So I have paid for FarmOs hosted on Farmier for one year. I am able to login into FarmOS without issues. However, when I try to login into Field-kit hosted on farmOS Field Kit I am getting CORS error from the Chrome console.

Access to XMLHttpRequest at 'https://bongo-farms.farmos.net/oauth2/token' from origin 'https://v1.farmos.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any ideas on how I can get this working? If you need to debug, I can create a test account for you to test on my FarmOS instance.

Thank you very much,
Lawrence

1 Like

Hey Lawrence,

Presumably your farmOS instance on Farmier is 2.0, correct?

If that’s the case, it will not work with version 1.0 of Field Kit, https://v1.farmos.app. Instead, use the 2.0 version of Field Kit is hosted at https://farmos.app. It is only in alpha, so there are limited features and some known issues, but that’ll be your best bet.

1 Like

Hey @jgaehring

Yes, my farmOS instance is 2.0.

"farm": {
      "name": "bongo",
      "url": "https://bongo-farms.farmos.net",
      "version": "2.0.0-beta6",
      "system_of_measurement": "metric"
    }

However, as you suggested, I have also tried with the field kit hosted at https://farmos.app and got the same error or similar. Any ideas what I am doing wrong?

Thanks very much for your help,
Lawrence

1 Like

You can find out your version of farmOS by trying to go to /api at your farm’s url. e.g. https://myfarm.example.com/api (docs)

If that returns a page that includes the key meta.farm.version which starts with “2”, then you’re on farmOS 2.x.

If that doesn’t work (returns a HTTP 404), you can confirm you’re on farmOS 1.x by trying to go to /farm.json at your farm’s url. e.g. https://myfarm.example.com/farm.json (docs)

If that returns a page that includes the key api_version with a value of “1.0” then you’re on farmOS 1.x.

1 Like

Thanks @Symbioquine.

1 Like

Hm, I’m guessing something has changed server-side since 2.0.0-beta3, which is the last version I’d tested the current Field Kit version against. Can you confirm that this is the same error you’re seeing when using https://farmos.app?

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@mstenta I’m seeing something slightly different when trying to login to test.farmos.dev, a 400 with the following response:

{
  "error": "invalid_client",
  "error_description": "This client is invalid or must authenticate using a client secret"
}

This is no doubt a result of the pause in Field Kit’s development, which has unfortunately not kept pace with farmOS. I’m resuming active development this week, however, so should hopefully be able to resolve this in short order.

Hi @jgaehring

I get this error

Access to XMLHttpRequest at 'https://bongo-farms.farmos.net/oauth/token' from origin 'https://farmos.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Thanks,
Lawrence

1 Like

@jgaehring Hmm I’m not sure why that stopped working! I don’t think anything has changed in the server code. The client ID that it is expecting is fieldkit - but I can’t imagine that’s changed in farmOS.app either, right?

@Dhliwayo sorry but Farmier might not be your best option if you want to experiment with Field Kit right now. The farmOS Field Kit module is disabled by default, because farmOS.app is still in alpha, which explains why you are getting that error. I installed in on https://test.farmos.dev for @jgaehring to do testing.

My plan is to allow users to enable it themselves when it is stable and there are Field Modules available - otherwise it will cause confusion/frustration because you can’t really do anything with it.

Right now Farmier should be thought of as a “default” farmOS deployment - you can’t upload custom modules/code, so if you are interested in experimenting with your own Field Kit development you would really be better off self-hosting farmOS at this point. I’d love to offer more advanced hosting options in the future, but right now it’s pretty much “default” farmOS hosting, with the main purpose of making it easy for people to get up and running with their record keeping on farmOS. That keeps things a whole lot simpler, which allows me to keep the hosting price low.

Hope that all makes sense! If you’re interested in joining one of our weekly development calls I’d be happy to help get you set up to play around with this stuff! It would be great to see more experimentation with Field Kit and Field Modules moving forward!

2 Likes

Ah, thanks Mike. Forgot where we left the default settings for farmOS. This all makes sense, just need to get my butt in high gear on reaching Field Kit beta!

3 Likes

@mstenta thank you for your reply.

Thanks for the invitation to participate in the weekly dev call. I would be really glad to participate, thanks.

So using Farmier (I have already paid for a year’s subscription :slight_smile: ) what options do I have for offline record keeping/syncing on the mobile (android or PWA). Does Farmier work with any version of the old farmOS Field Kit?

2 Likes

Since Farmier is just “default farmOS”, and farmOS itself doesn’t have any built-in offline features, then I’m afraid there isn’t much to offer in terms of offline right now. If that was the main reason you subscribed and you won’t find it useful otherwise, send me a PM and I’ll be happy to refund you for the time spent!

1 Like