jamesknelson / create-react-blog

Start and deploy your own statically rendered blog with create-react-app
https://create-react-blog.netlify.com/
MIT License
550 stars 69 forks source link

Help for anyone with the error "Couldn't find window.NaviScripts - did you call register()?" #30

Open ArchieHicklin opened 3 years ago

ArchieHicklin commented 3 years ago

Thank you for making this boilerplate.

As a few others have found this error and is easily reproducible if you try to build this project using recent Node or Yarn.

[ohshit] An error occured while building your app Couldn't find window.NaviScripts - did you call register()?

I just spent yesterday trying to debug this as had used this project for a deadline and didn't check whether building worked until deadline day 😭. I'd spent a couple weeks developing locally and was worried I'd made a terrible mistake and assumed it was a spiritual successor to CRA in terms of ease of use.

Here's how I got things built and deployed in Netlify (just in case you're using it to deploy):

Yarn will not work you must use npm. And you must use 11.15.0. Please use node version manager to set the correct version of node nvm use 11.15.0

You must edit the build command in Netlify to CI= npm run build this is because any warnings will be treated as errors as your build will fail.

Publish directory is build/

In your environment variables you must set NODE_VERSION 11.15.0

If you use these settings your build will succeed and you can publish your deploy.

Hope this helps anyone who was in a similar position. Please let me know if anything needs clarifying.

tomwojcik commented 3 years ago

Just run into the same problem.

.node-version file with 11.15.0 solves it as well (for netlify).

upstream ticket https://github.com/frontarm/navi/issues/92