Home
Support Forums

Javascript doesn't run the same as my local version

Hi there everyone, my site - randocolorgenerator.netlify.app - has just had a new deployment after I completed a change I was excited to get live. The code works perfectly on my local machine, I use Parcel to build my project. But when I deployed my latest release, something went wrong. I noticed the code didn’t work as expected, and in the dev tools, there seemed to be an error in my index.[hash].js file.

Also, because my site is now broken, I wanted to revert to a previous deployment, which I did, except the site has remained exactly the same, even though netlify says it’s published my previous deployment that was working, the site still has the new seemingly broken code, and I’m worried that I’m just stuck with a broken site now.

The build log for the deployment is here:

11:51:18 AM: Build ready to start
11:51:21 AM: build-image version: 7e10faf349e7a42e522e4b38297aec45774c71a6 (focal)
11:51:21 AM: build-image tag: v4.4.1
11:51:21 AM: buildbot version: 45cff7af059cf0b14f28f2a5245780d067b7e413
11:51:21 AM: Fetching cached dependencies
11:51:21 AM: Starting to download cache of 180.1MB
11:51:22 AM: Finished downloading cache in 994.880356ms
11:51:22 AM: Starting to extract cache
11:51:28 AM: Finished extracting cache in 5.715451125s
11:51:28 AM: Finished fetching cache in 6.811302476s
11:51:28 AM: Starting to prepare the repo for build
11:51:28 AM: Preparing Git Reference refs/heads/main
11:51:29 AM: Parsing package.json dependencies
11:51:30 AM: Starting build script
11:51:30 AM: Installing dependencies
11:51:30 AM: Python version set to 2.7
11:51:30 AM: Started restoring cached node version
11:51:32 AM: Finished restoring cached node version
11:51:33 AM: v16.13.0 is already installed.
11:51:33 AM: Now using node v16.13.0 (npm v8.1.0)
11:51:33 AM: Started restoring cached build plugins
11:51:33 AM: Finished restoring cached build plugins
11:51:34 AM: Attempting ruby version 2.7.2, read from environment
11:51:35 AM: Using ruby version 2.7.2
11:51:35 AM: Using PHP version 8.0
11:51:35 AM: Started restoring cached node modules
11:51:35 AM: Finished restoring cached node modules
11:51:36 AM: Started restoring cached go cache
11:51:36 AM: Finished restoring cached go cache
11:51:36 AM: go version go1.16.5 linux/amd64
11:51:36 AM: go version go1.16.5 linux/amd64
11:51:36 AM: Installing missing commands
11:51:36 AM: Verify run directory
11:51:37 AM: ​
11:51:37 AM: ────────────────────────────────────────────────────────────────
11:51:37 AM: Netlify Build
11:51:37 AM: ────────────────────────────────────────────────────────────────
11:51:37 AM: ​
11:51:37 AM: ❯ Version
11:51:37 AM: @netlify/build 18.21.9
11:51:37 AM: ​
11:51:37 AM: ❯ Flags
11:51:37 AM: baseRelDir: true
11:51:37 AM: buildId: 618d03b6595850000713e32e
11:51:37 AM: deployId: 618d03b6595850000713e330
11:51:37 AM: ​
11:51:37 AM: ❯ Current directory
11:51:37 AM: /opt/build/repo
11:51:37 AM: ​
11:51:37 AM: ❯ Config file
11:51:37 AM: No config file was defined: using default values.
11:51:37 AM: ​
11:51:37 AM: ❯ Context
11:51:37 AM: production
11:51:37 AM: ​
11:51:37 AM: ────────────────────────────────────────────────────────────────
11:51:37 AM: 1. Build command from Netlify app
11:51:37 AM: ────────────────────────────────────────────────────────────────
11:51:37 AM: ​
11:51:37 AM: $ npm run build
11:51:38 AM: > randomcolorgenerator@1.0.0 build
11:51:38 AM: > parcel build index.html --dist-dir ./dist
11:51:38 AM: Building…
11:51:40 AM: Bundling…
11:51:41 AM: Packaging & Optimizing…
11:51:45 AM: :sparkles: Built in 7.44s
11:51:45 AM: dist/index.html 733 B 4.47s
11:51:45 AM: dist/index.cde87657.css 4.04 KB 1.92s
11:51:45 AM: dist/index.9ff61b6f.js 134.29 KB 4.42s
11:51:45 AM: dist/icons.2327b9ee.svg 2.26 KB 1.95s
11:51:46 AM: ​
11:51:46 AM: (build.command completed in 8.3s)
11:51:46 AM: ​
11:51:46 AM: ────────────────────────────────────────────────────────────────
11:51:46 AM: 2. Deploy site
11:51:46 AM: ────────────────────────────────────────────────────────────────
11:51:46 AM: ​
11:51:46 AM: Starting to deploy site from ‘dist’
11:51:46 AM: Creating deploy tree
11:51:46 AM: Creating deploy upload records
11:51:46 AM: 0 new files to upload
11:51:46 AM: 0 new functions to upload
11:51:46 AM: Site deploy was successfully initiated
11:51:46 AM: ​
11:51:46 AM: (Deploy site completed in 134ms)
11:51:46 AM: ​
11:51:46 AM: ────────────────────────────────────────────────────────────────
11:51:46 AM: Netlify Build Complete
11:51:46 AM: ────────────────────────────────────────────────────────────────
11:51:46 AM: ​
11:51:46 AM: (Netlify Build completed in 8.5s)
11:51:46 AM: Starting post processing
11:51:46 AM: Post processing - HTML
11:51:46 AM: Post processing - header rules
11:51:46 AM: Post processing - redirect rules
11:51:46 AM: Post processing done
11:51:46 AM: Caching artifacts
11:51:46 AM: Started saving node modules
11:51:46 AM: Finished saving node modules
11:51:46 AM: Started saving build plugins
11:51:46 AM: Finished saving build plugins
11:51:46 AM: Started saving pip cache
11:51:46 AM: Finished saving pip cache
11:51:46 AM: Started saving emacs cask dependencies
11:51:46 AM: Site is live :sparkles:
11:51:46 AM: Finished saving emacs cask dependencies
11:51:46 AM: Started saving maven dependencies
11:51:46 AM: Finished saving maven dependencies
11:51:46 AM: Started saving boot dependencies
11:51:46 AM: Finished saving boot dependencies
11:51:46 AM: Started saving rust rustup cache
11:51:46 AM: Finished saving rust rustup cache
11:51:46 AM: Started saving go dependencies
11:51:46 AM: Finished saving go dependencies
11:51:46 AM: Build script success
11:52:19 AM: Finished processing build request in 58.09401253s

Hi @raspberrymousse

This is what I see when I visit your site

The current published version of your site does not appear broken to me. The only error I am seeing in DevTools is a failure to load /favicon.ico.

Are you able to share the deploy preview URL to the latest deploy where you see this error?

Also, this makes me think nothing actually changed in your builds?

Hi @coelmay

https://618d044db2011920a0db65e2--randocolorgenerator.netlify.app/

Do you see a heart at the top-left of the page? If so, click it to like the colour, then you should see a button in the top-right labelled “Your Likes”, when I click it locally, it displays all previously liked colours, but when I do this on the deployed version it doesn’t display them.

Hi @hrishikesh,

Do you think it’s possible there’s a problem with the github integration, and I’d be better off deploying my site manually?

I’m seeing it just fine:

I don’t think so, but if you feel you need to deploy manually, you can do so via the CLI.

@hrishikesh @coelmay It’s working for me now, I’m very confused as to what was happening, the index.js file no longer shows the error either, sorry this seems to have just been a waste of time. Thanks for replying so quickly