Https://mariav.art/.netlify/functions/submission-created

site name: mariav.art

Jun 28, 03:39:58 AM: 95f757c8 2022-06-28T00:39:58.363Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jun 28, 03:39:58 AM: 95f757c8 2022-06-28T00:39:58.610Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jun 28, 03:39:58 AM: 95f757c8 Unknown application error occurredJun 28, 03:39:58 AM: 95f757c8 Runtime.UserCodeSyntaxError
Jun 28, 03:39:58 AM: 95f757c8 Duration: 210.33 ms	Memory Usage: 13 MB	Jun 28, 03:46:49 AM: 10aff5f6 2022-06-28T00:46:50.592Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jun 28, 03:46:49 AM: 10aff5f6 2022-06-28T00:46:50.845Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jun 28, 03:46:49 AM: 10aff5f6 Unknown application error occurredJun 28, 03:46:49 AM: 10aff5f6 Runtime.UserCodeSyntaxError
Jun 28, 03:46:49 AM: 10aff5f6 Duration: 215.33 ms	Memory Usage: 13 MB

hi maria, looks like you have some errors in your code. does this work locally?

it works fine in vscode, if you have live server, and live javascript compiler add-ons, enabled, do you see how could i debug in netlify? thanks in advance!!!

hi there Maria, I’m sorry, but you’ll need to provide more information and maybe show us some error messages, logging, screenshots,that kind of thing! it is very difficult for us to really say in this context.

1 Like
Let 's get Creative Javascript
<style>

@import url(β€˜https://fonts.googleapis.com/css2?family=Brygada+1918:ital@1&family=Sofia&display=swap’);

Like @perry said: can you share the full content of submission-created.js, the function logs and your deployment logs? The code you shared is css, not javascript.

i pasted the whole code from deploy-succeeded.js
but your paste function accepted only a part… i will re-paste immediately

<!DOCTYPE html>
<html>
<body>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Let 's get Creative</title>
    <link rel='stylesheet' type='text/css' media='screen' href='styles.css'>
    <title>Javascript</title> 
        
</head>
    
<body>
    
    <style>
@import url('https://fonts.googleapis.com/css2?family=Brygada+1918:ital@1&family=Sofia&display=swap');
</style>

<script>
    
  canvas#poster-canvas(width='500px' height='700px')
    images/Background.jpg 
    
    function initCanvas() {
  canvasCtx = document.getElementById("poster-canvas").getContext('2d');
}
    
    img.poster-background(src='images/Background.jpg')
    
    $('img.poster-background').on('load', function () {
  var backgroundImg = $('img.poster-background')[0];
  canvasCtx.drawImage(backgroundImg, width='500px' 'height=700px;');
  renderName();
});
    
    function renderText() {
  var text = $('input[text="chText"]').val();
  var fontSize;
  if (text.length < 3) {
    fontSize = 100;
  } else {
    fontSize = parseInt(320 / text.length);
  }
  canvasCtx.font = "bold " + fontSize + "px https://fonts.googleapis.com/css2?family=Brygada+1918:ital@1&family=Sofia&display=swap";
  canvasCtx.fillStyle = "#de071b";
  canvasCtx.fillText(text);
        
        a.upload-btn 
  input#photo(type='file' name='photo' accept='image/jpeg, image/png, image/jpg, image/gif, image/psd')
        
        .upload-btn input {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 68px;
  cursor: pointer;
}
        
        $('#photo').on('change', function (e) {
  var file = e.target.files[0];
  var type = file.type;
  if (type !== 'image/jpg' && type !== 'image/gif') {
    window.toastr.error ('Please upload JPG or GIF format picture ');
  } else {
    var formData = new FormData();
    formData.append('avatar', file);
    $.ajax({
      type: 'POST',
      url: '/upload_url',
      data: formData,
      contentType: false,
      processData: false,
      success: function(result) {
        var avatarUrl = result.data.url;
        $('img.avatar').attr('src', avatarUrl);
      },
        
        document.getElementById("poster-canvas").toBlob(function (blob) {});
        
        var blob = dataURLtoBlob(document.getElementById("poster-canvas").toDataURL());

function dataURLtoBlob(dataurl) {
  if (dataurl.indexOf('base64') < 0) {
    dataurl = 'data:image/jpeg;base64,' + dataurl;
  }
  var arr = dataurl.split(',');
  var mime = arr[0].match(/:(.*?);/)[1];
  var bstr = atob(arr[1]);
  var n = bstr.length;
  var u8arr = new Uint8Array(n);
  while (n --) {
    u8arr[n] = bstr.charCodeAt(n);
  }
  return new Blob([u8arr], {type: mime});
}
        
        var formData = new FormData();
formData.append('poster', blob);
$.ajax({
  type: 'POST',
  url: '/upload_poster_url',
  data: formdata,
  contentType: false,
  processData: false,
  success: function(result) {
    
  },
  error: function(err) {
    
  }  
    
}

 
</script>
</body>
</html>

i am sorry, but it does not accept the full code…





8:29:55 PM: build-image version: 0e2f4c52031ab562db66aec633308326e3b108d0 (focal)
8:29:55 PM: build-image tag: focal
8:29:55 PM: buildbot version: 8dba8e08e1359f22ae92654e177dea552324c91c
8:29:55 PM: Fetching cached dependencies
8:30:03 PM: Finished downloading cache in 7.402882743s
8:30:03 PM: Starting to extract cache
8:30:12 PM: Finished extracting cache in 9.342978384s
8:30:12 PM: Finished fetching cache in 16.989953401s
8:30:12 PM: Starting to prepare the repo for build
8:30:13 PM: Preparing Git Reference refs/heads/main
8:30:16 PM: Parsing package.json dependencies
8:30:17 PM: Starting build script
8:30:17 PM: Installing dependencies
8:30:17 PM: Python version set to 2.7
8:30:17 PM: Started restoring cached node version
8:30:21 PM: Finished restoring cached node version
8:30:21 PM: v16.15.1 is already installed.
8:30:22 PM: Now using node v16.15.1 (npm v8.11.0)
8:30:22 PM: Started restoring cached build plugins
8:30:22 PM: Finished restoring cached build plugins
8:30:22 PM: Attempting ruby version 2.7.2, read from environment
8:30:23 PM: Using ruby version 2.7.2
8:30:24 PM: Using PHP version 8.0
8:30:24 PM: Started restoring cached go cache
8:30:24 PM: Finished restoring cached go cache
8:30:24 PM: Installing Go version 1.17 (requested 1.17)
8:30:34 PM: unset GOOS;
8:30:34 PM: unset GOARCH;
8:30:34 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
8:30:34 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
8:30:34 PM: go version >&2;
8:30:34 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
8:30:34 PM: go version go1.17 linux/amd64
8:30:34 PM: Installing missing commands
8:30:34 PM: Verify run directory
8:30:35 PM: ​
8:30:35 PM: ────────────────────────────────────────────────────────────────
8:30:35 PM:   Netlify Build                                                 
8:30:35 PM: ────────────────────────────────────────────────────────────────
8:30:35 PM: ​
8:30:35 PM: ❯ Version
8:30:35 PM:   @netlify/build 27.3.1
8:30:35 PM: ​
8:30:35 PM: ❯ Flags
8:30:35 PM:   baseRelDir: true
8:30:35 PM:   buildId: 62bf2f11bab5b30eb62cdec1
8:30:35 PM:   deployId: 62bf2f11bab5b30eb62cdec3
8:30:35 PM: ​
8:30:35 PM: ❯ Current directory
8:30:35 PM:   /opt/build/repo
8:30:35 PM: ​
8:30:35 PM: ❯ Config file
8:30:35 PM:   No config file was defined: using default values.
8:30:35 PM: ​
8:30:35 PM: ❯ Context
8:30:35 PM:   production
8:30:35 PM: ​
8:30:35 PM: ❯ Loading plugins
8:30:35 PM:    - netlify-plugin-submit-sitemap@0.4.0 from Netlify app
8:30:35 PM:    - netlify-plugin-no-more-404@0.0.15 from Netlify app
8:30:37 PM: ​
8:30:37 PM: ────────────────────────────────────────────────────────────────
8:30:37 PM:   1. Functions bundling                                         
8:30:37 PM: ────────────────────────────────────────────────────────────────
8:30:37 PM: ​
8:30:37 PM: Packaging Functions from netlify/functions directory:
8:30:37 PM:  - deploy-succeeded.js
8:30:37 PM: ​
8:30:37 PM: ​
8:30:37 PM: (Functions bundling completed in 142ms)
8:30:37 PM: ​
8:30:37 PM: ────────────────────────────────────────────────────────────────
8:30:37 PM:   2. netlify-plugin-no-more-404 (onPostBuild event)             
8:30:37 PM: ────────────────────────────────────────────────────────────────
8:30:37 PM: ​
8:30:37 PM: html manifest saved for next run
8:30:37 PM: ​
8:30:37 PM: (netlify-plugin-no-more-404 onPostBuild completed in 188ms)
8:30:37 PM: ​
8:30:37 PM: ────────────────────────────────────────────────────────────────
8:30:37 PM:   3. Deploy site                                                
8:30:37 PM: ────────────────────────────────────────────────────────────────
8:30:37 PM: ​
8:30:37 PM: Starting to deploy site from '/'
8:30:38 PM: Creating deploy tree 
8:30:38 PM: Creating deploy upload records
8:30:38 PM: ---------------------------------------------------------------------** WARNING **The default Node.js runtime will change to Node v16 on 2022-07-11.If you need to stay on v14, refer to https://ntl.fyi/pin-js-runtime.---------------------------------------------------------------------
8:30:39 PM: 0 new files to upload
8:30:39 PM: 0 new functions to upload
8:30:39 PM: Starting post processing
8:30:39 PM: Post processing - HTML
8:30:39 PM: Processing form - frmContact
8:30:39 PM: Detected form fields: - txtName - txtEmail - txtMessage
8:30:40 PM: Post processing - header rules
8:30:40 PM: Post processing - redirect rules
8:30:40 PM: Post processing done
8:30:44 PM: Site is live ✨
8:30:45 PM: Finished waiting for live deploy in 6.071610111s
8:30:45 PM: Site deploy was successfully initiated
8:30:45 PM: ​
8:30:45 PM: (Deploy site completed in 7.7s)
8:30:45 PM: ​
8:30:45 PM: ────────────────────────────────────────────────────────────────
8:30:45 PM:   4. netlify-plugin-submit-sitemap (onSuccess event)            
8:30:45 PM: ────────────────────────────────────────────────────────────────
8:30:45 PM: ​
8:30:45 PM: Going to submit sitemap to google
8:30:45 PM:  --> URL: https://www.google.com/ping?sitemap=https://mariav.art/sitemap.xml
8:30:45 PM: Going to submit sitemap to yandex
8:30:45 PM:  --> URL: https://webmaster.yandex.ru/ping?sitemap=https://mariav.art/sitemap.xml
8:30:45 PM:  βœ“ DONE! Sitemap submitted succesfully to google 
8:30:45 PM:  βœ“ DONE! Sitemap submitted succesfully to yandex 
8:30:45 PM: ​
8:30:45 PM: (netlify-plugin-submit-sitemap onSuccess completed in 735ms)
8:30:46 PM: ​
8:30:46 PM: ────────────────────────────────────────────────────────────────
8:30:46 PM:   Netlify Build Complete                                        
8:30:46 PM: ────────────────────────────────────────────────────────────────
8:30:46 PM: ​
8:30:46 PM: (Netlify Build completed in 10.6s)
8:30:46 PM: Caching artifacts
8:30:46 PM: Started saving build plugins
8:30:46 PM: Finished saving build plugins
8:30:46 PM: Started saving pip cache
8:30:46 PM: Finished saving pip cache
8:30:46 PM: Started saving emacs cask dependencies
8:30:46 PM: Finished saving emacs cask dependencies
8:30:46 PM: Started saving maven dependencies
8:30:46 PM: Finished saving maven dependencies
8:30:46 PM: Started saving boot dependencies
8:30:46 PM: Finished saving boot dependencies
8:30:46 PM: Started saving rust rustup cache
8:30:46 PM: Finished saving rust rustup cache
8:30:46 PM: Started saving go dependencies
8:30:46 PM: Finished saving go dependencies
8:30:46 PM: Build script success
8:31:40 PM: Finished processing build request in 1m44.41341473s
Jul 1, 08:09:05 PM: 9b41fa7e 2022-07-01T17:09:05.780Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jul 1, 08:09:05 PM: 9b41fa7e 2022-07-01T17:09:06.041Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jul 1, 08:09:05 PM: 9b41fa7e Unknown application error occurredJul 1, 08:09:05 PM: 9b41fa7e Runtime.UserCodeSyntaxError
Jul 1, 08:09:05 PM: 9b41fa7e Duration: 214.46 ms	Memory Usage: 13 MB	Jul 1, 08:30:46 PM: 05f00aa3 2022-07-01T17:30:47.033Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jul 1, 08:30:46 PM: 05f00aa3 2022-07-01T17:30:47.302Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '<'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '<'","    at _loadUserApp (/var/runtime/UserFunction.js:218:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)","    at Object.<anonymous> (/var/runtime/index.js:43:34)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)","    at internal/main/run_main_module.js:17:47"]}Jul 1, 08:30:46 PM: 05f00aa3 Unknown application error occurredJul 1, 08:30:46 PM: 05f00aa3 Runtime.UserCodeSyntaxError
Jul 1, 08:30:46 PM: 05f00aa3 Duration: 222.46 ms	Memory Usage: 13 MB

You’re trying to return a html page from your function, it isn’t actual javascript. That’s not quite how Netlify functions work. Have a look at the documentation:

And a couple of examples:

you probably know that javascript is not a stand-alone programing language, it is hosted in html enviroment. now if for this function to work i should remove the html part, i will happily do so… thank you in advance for your time and effort!!! :slight_smile:

I do, it’s just that serverless functions, like Netlify Functions, are not part of the front-end at all. They serve the single purpose of returning data.

1 Like

so, apart from functions, what would be your suggestion for embending a javascript app to a static website in Netlify??? i mean, i have this idea, like creating the javascript app as a stand-alone app, and embending it at the last page of the website… but then i am not so sure that deploy on the site would succed as a whole…!

You can simply deploy a html file that contains the javascript, or loads it in a script tag.

1 Like

Thanks a lot all of you for your kind assistance, I re- wrote the code from scratch and it worked… Seems the main reason for not working properly was that it requires it’s own directory… Anyway, I can now finally say that I have solved the problem!!! :slight_smile:

Thank you so much for coming back and letting us know! Glad everything is working now. Happy building :rocket: