complete-javascript-course icon indicating copy to clipboard operation
complete-javascript-course copied to clipboard

Uploading to netlify gives error when trying to use application

Open amgj-dev opened this issue 3 years ago • 7 comments

Building on netlify is working, but when i go to the address to test the application nothing works. So i inspected console which has this message: Uncaught ReferenceError: Fraction is not defined at View.js:131

I have been beating my head against the wall with this, when using npm start, everything works. when i build locally and run it with live server, everything also works. But when i upload it to netlify this error shows.

I tried a lot of different things to fix this. If i remove fractional completely everything works on netlify. I tried adding the fractional index.html to my js folder and importing that instead, again all is working locally, but once on netlify i get the same error. I even tried to get the final code from this repo to upload to netlify, and i still get the same, working locally but throws the same error in netlify. I had someone try to help me at netlify forums, he would get the same error, but when building locally said the final code from this repo was working, but mine was not. so suggested it might be some changes i made to the code, but there is not that big of a difference to the two codes.

I can not understand why this happens, or especially why it is thrown in View.js renderMessage at the line 'this._clear()'. Just to test i tried importing fractional into View.js also, and then it instead it throws the same error in runtime-(some random numbers).js

I am starting my MVC course today, but i would still like to get this fixed, and more importantly understand what is happening.

https://forkify-aj.netlify.app/ https://github.com/amgj-dev/Forkify

amgj-dev avatar Oct 27 '21 09:10 amgj-dev

I am having the exact same problem. I think that netlify simply doesn't install Fractional.

jbednar97 avatar Oct 29 '21 11:10 jbednar97

It is the problem with Fractional. Installing a different package like Fracty should help.

akozdev avatar Oct 29 '21 11:10 akozdev

It is the problem with Fractional. Installing a different package like Fracty should help. I've managed to change Fractional for fracty, but now I'm logging : controller.js:33 ReferenceError: _fracty is not defined

I'm afraid that fracty also isn't the solution.

jbednar97 avatar Oct 29 '21 11:10 jbednar97

That's strange. Have you changed the code in recipeView.js file to import fracty from "fracty"; and then this line ing.quantity ? new Fraction(ing.quantity).toString() : '' to ing.quantity ? fracty(ing.quantity).toString() : ''; ?

akozdev avatar Oct 29 '21 11:10 akozdev

That's strange. Have you changed the code in recipeView.js file to import fracty from "fracty"; and then this line ing.quantity ? new Fraction(ing.quantity).toString() : '' to ing.quantity ? fracty(ing.quantity).toString() : ''; ?

Yes I did, however fracty(ing.quantity) haven't been working, i had to use _fractry(ing.quantity) in order to work for me. I've also tried deploying with all possible options so with under-score and without too. There is my link to my repo if you'd like to check it out. https://github.com/jbednar97/Forkify-Jakub/blob/master/src/js/views/recipeView.js

jbednar97 avatar Oct 29 '21 14:10 jbednar97

Can you try with this repo https://github.com/akozdev/Forkify-Fracty-Parcel2? I used latest version of Fracty and Parcel. It should work out of the box.

akozdev avatar Nov 22 '21 12:11 akozdev

-- First, make sure you don't have a typo at import { Fraction } from 'fractional'; -- Install [email protected] -- change your build path: "build": "parcel build --no-minify index.html --dist-dir ./dist"

npm i [email protected]
npm i fractional
npm i -D babel-core babel-polyfill babel-preset-es2015 babel-preset-stage-0 babel-loader

After that you may have another error: [ regeneratorRuntime is not defined ] at helpers.js import { async } from 'regenerator-runtime';

This works for me https://forkify-adriel.netlify.app/

androidrun avatar Jan 14 '22 23:01 androidrun