Error: Did you forget to run "frontity build"?

Hi @modyydom! Sorry for the stress! :slightly_smiling_face:

2 questions for you:

  1. Does the Error: Cannot read property 'flags' of undefined have a stacktrace? Could you provide it? It should point us to the problem.
  2. Every single google search result on the first page points with for ā€œError: Cannot read property ā€˜flagsā€™ of undefinedā€ seems to point to a typescript or angular issue like this one or that one. Are you using TS in the project and are you sure that itā€™s not a TS issue?

Thank very much @mmczaplinski
1- unfortunately There is NO stacktrace for this issue
this is all what I get

2- Iā€™m not using any TS code :frowning:

An internal param called flags is used by one of the libraries we use in the CLI, commander so I guess the problem may be there. Iā€™m going to investigate.

Iā€™ve just started a fresh project on Windows 10 and it works fine.

Things you can try:

  • Search for ".flags" in your code. Make sure the error is not in your code.
  • Run npx frontity dev -p and check if you see any error in your code that only happens in production mode.
  • Remove node_modules and package-lock.json, update all packages and do npm install again. Follow this guide: https://docs.frontity.org/guides/keep-frontity-updated
  • Try with both npm run dev or npx frontity dev to see if it makes a difference.

If the problem persists, check the version of commander with:

npm ls | find "commander"

I am running 2.20.3 here and it works fine here in Windows 10.

I found the cause of the problem

it is due to importing react-slick

I found also this behavior

The site is WORKING well in these situations:

  • On Zeit now server
  • With npx frontity dev
  • With npx frontity dev -p
  • When running npx frontity serve AFTER npx frontity dev

The site is NOT working in these situations:

  • When running npx frontity serve AFTER npx frontity build
  • When running npx frontity serve AFTER npx frontity dev -p

I donā€™t know what in zeit now that makes it working that is not in the npx frontity build

Iā€™m sorry again for being so late and I really thankful of your efforts in helping me

Thanks @modyydom, I was able to reproduce the issue. The problem is caused by the TypeScript compiler interacting with react-slick in production mode.

I am not sure about the reason, but itā€™s not a good idea to run the TypeScript compiler on frontity serve, so I have filed a bug to get rid of that: https://github.com/frontity/frontity/issues/355

Until we fix that issue, you can create a file that does the require itself and run that, like this:

const serve = require("@frontity/core/dist/src/scripts/serve").default;

serve({
  isHttps: false,
  port: 3000
});

You can take a look at this repo to see a full example:

Let me know if that solves your problem :slight_smile:

2 Likes

Thatā€™s Great

It is working perfectly :smiley:

2 Likes

please fix this problem
i can not deploy this on Now.

Hi @prainua, thanks a lot for the feedback and sorry for the inconvenience this may have caused :slightly_smiling_face: Weā€™ve just bumped up the priority of this bug and it should be addressed in the coming weeks. Weā€™ll keep track of it at the GitHub issue.

Fixed in our last release by @mmczaplinski.

I still have a error. I updated to the latest version.

npx npm-check-updates -u
npm install

Hi @prainua

Did you try the solution provided above? ā†’ Error: Did you forget to run "frontity build"?

If itā€™s still not working, can you please provide the info suggested here?

The more info you provide about your issue the better. Providing a repo or code-sandbox with your code is especially helpful to find solutions of technical issues with specific code

Hey @juanma. I am also facing this issue and I am totally stuck. I cant even figure out how to start debugging it.

npx frontity build completes without issue
npx frontity serve fails with the following message:

donkoko惃: ~/devs/JS/kh-frontity-theme [git:live]
$ npx frontity serve

Error: Cannot read property 'flags' of undefined

If you need help please visit https://community.frontity.org/.

Happens to me also on the live server, that is how I found the issue. I have made a github action that uses ssh to connect to server, pull from github, build the app and run npx frontity serve but it fails in the last step because of this error.

Hi @ni.bonev,

Can you check the following?

In these are OK, can you please provide a repo or code-sandbox with your code? This is especially helpful to find solutions of technical issues with specific code

Hey @juanma,

I have done all of this multiple times, unfortunatelly that didnā€™t bring me further. I also saw the other posts mentioning the same issue and they both have very different causes, thatā€™s why I was wondering if I can somehow log more information or see the full stack.
I can provide a github repo, but its private. Can you give me your github user and I can add you?

Hi @ni.bonev,

Unfortunately we donā€™t provide support to private repositories.

Could you replicate your issue (only the portion of the code that provokes the issue) in a public repository (or codesandbox) so any member of the community (Frontity team included) can help you with your issue?

1 Like

Hi @ni.bonev !

Could you run npx frontity info (Iā€™d like to see if you are using any packages that might be causing this issue and what version of node youā€™re on)

Also, just to let you know: This is unfortunately an issue with one of frontityā€™s dependencies and not with frontity itself.

It doesnā€™t, of course, mean that itā€™s less important, just that we might have less ability to fix it and to fix it quickly - sorry about this!

2 Likes

Hey @mmczaplinski,

thank you so much for coming back to me about this. I was already getting to start desperate.
Just to say a few things, also referring to @juanmaā€™s answer.

I completely understand the situation and I donā€™t expect you guys to debug/fix my issue. It is however something that was suggested so I wanted to offer access to my repository.

This aside, all I wanted was to get some help with debugging this and getting to the bottom of it, as I am completely clueless how to find the issue in a situation where the error is so vague. I would love to find the solution, just some directions are needed :slight_smile:

Here is the output from npx frontity info

šŸ§Ÿ $ npx frontity info

## System:
 - OS: macOS 10.15
 - CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
 - Memory: 25.62 MB / 8.00 GB
 - Shell: 5.0.18 - /usr/local/bin/bash
## Binaries:
 - Node: 10.14.2 - /usr/local/bin/node
 - npm: 6.14.8 - /usr/local/bin/npm
## Browsers:
 - Chrome: 86.0.4240.75
 - Edge: 86.0.622.38
 - Firefox: 70.0
 - Safari: 13.0.2
## npmPackages:
 - @frontity/core: ^1.7.3 => 1.9.0
 - @frontity/head-tags: ^1.0.5 => 1.0.7
 - @frontity/html2react: ^1.3.5 => 1.4.0
 - @frontity/koenighaus-theme: ./packages/koenighaus-theme => 1.4.2
 - @frontity/tiny-router: ^1.2.1 => 1.2.1
 - @frontity/wp-source: ^1.8.1 => 1.9.0
 - @hookform/error-message: 0.0.4 => 0.0.4
 - axios: ^0.19.2 => 0.19.2
 - frontity: ^1.10.1 => 1.12.0
 - frontity-contact-form-7: ^0.1.7 => 0.1.7
 - js-cookie: ^2.2.1 => 2.2.1
 - libphonenumber-js: ^1.7.57 => 1.8.2
 - libphonenumber-js-core:  1.0.0
 - libphonenumber-js-max:  1.0.0
 - libphonenumber-js-min:  1.0.0
 - libphonenumber-js-mobile:  1.0.0
 - react-hook-form: ^6.4.1 => 6.8.6
 - react-select: ^3.1.0 => 3.1.0
 - react-spring: ^8.0.27 => 8.0.27
 - woocommerce-shop: file:packages/woocommerce-shop => 1.0.0
## npmGlobalPackages:
 - frontity: Not Found
 - npx: Not Found

Hey @ni.bonev, could you please try using a ā€œmanual serveā€ to see if the problem is in our npx frontity serve command?

Something like this: https://github.com/luisherranz/frontity-react-slick/commit/86df2ad6b53db235f10230e953b410d8c8ba2f7a