Azure web app service deployment failure saying "SyntaxError: Unexpected token" after updating VS Code

user1186050

UPDATE 5/18/23 - I updated this in Azure application setting from 6.9.1 to 18 (node version I'm using) and now I can deploy successfully again.

WEBSITE_NODE_DEFAULT_VERSION

PROBLEM

I'm not sure why my deployment is failing. I had this issue before in VS Code 1.65 to 1.66 and had to stay on 1.65. There was a VS Code update to 1.78.2 from whatever the previous version I was on.

I tried downgrading to the March 2023 version of VS Code and retried deployment, but still had the same failure. (FYI - still had version 1.78.2 open and running as I tried to perform a deploy using the March version) so don't know if that makes a difference?

Here is what I see in the output. I'm not sure what this means? How can I debug this? I have application logging turned on in Azure, but don't see anything in the log stream when I try to deploy. I also opened Kudu (*.scm.azurewebsites.net) and looked through the files but didn't see anything useful. Maybe I'm not familiar enough with Kudu to understand how to use it to debug a failed deployment.

    6:42:56 PM yoga-dev-1: Starting deployment...
    6:42:59 PM yoga-dev-1: Creating zip package...
    6:43:10 PM yoga-dev-1: Zip package size: 29 MB
    6:43:10 PM yoga-dev-1: Fetching changes.
    6:43:11 PM yoga-dev-1: Cleaning up temp folders from previous zip deployments and extracting pushed zip file C:\local\Temp\zipdeploy\qkztvba1.zip (27.71 MB) to C:\local\Temp\zipdeploy\extracted
    6:43:17 PM yoga-dev-1: Updating submodules.
    6:43:17 PM yoga-dev-1: Preparing deployment for commit id '7e83110e5b'.
    6:43:17 PM yoga-dev-1: Generating deployment script.
    6:43:17 PM yoga-dev-1: Using the following command to generate deployment script: 'azure site deploymentscript -y --no-dot-deployment -r "C:\local\Temp\zipdeploy\extracted" -o "C:\home\site\deployments\tools" --basic --sitePath "C:\local\Temp\zipdeploy\extracted"'.
    6:43:18 PM yoga-dev-1: C:\PROGRA~2\SITEEX~1\NODEAP~1\296456~1.8
    6:43:18 PM yoga-dev-1: odejs\build\src\Loader.js:153
    6:43:18 PM yoga-dev-1:                 ...StatusLogger.DEFAULT_STATUS,
    6:43:18 PM yoga-dev-1:                 ^^^
    6:43:18 PM yoga-dev-1: SyntaxError: Unexpected token ...
    6:43:18 PM yoga-dev-1:     at createScript (vm.js:56:10)
    6:43:18 PM yoga-dev-1:     at Object.runInThisContext (vm.js:97:10)
    6:43:18 PM yoga-dev-1:     at Module._compile (module.js:542:28)
    6:43:18 PM yoga-dev-1:     at Object.Module._extensions..js (module.js:579:10)
    6:43:18 PM yoga-dev-1:     at Module.load (module.js:487:32)
    6:43:18 PM yoga-dev-1:     at tryModuleLoad (module.js:446:12)
    6:43:18 PM yoga-dev-1:     at Function.Module._load (module.js:438:3)
    6:43:18 PM yoga-dev-1:     at Module.require (module.js:497:17)
    6:43:18 PM yoga-dev-1:     at module.js:669:12
    6:43:18 PM yoga-dev-1:     at Array.forEach (native)
    6:43:18 PM yoga-dev-1: C:\PROGRA~2\SITEEX~1\NODEAP~1\296456~1.8
    6:43:18 PM yoga-dev-1: odejs\build\src\Loader.js:153\r
    6:43:18 PM yoga-dev-1:                 ...StatusLogger.DEFAULT_STATUS,\r
    6:43:18 PM yoga-dev-1:                 ^^^\r
    6:43:18 PM yoga-dev-1: \r
    6:43:18 PM yoga-dev-1: SyntaxError: Unexpected token ...\r
    6:43:18 PM yoga-dev-1:     at createScript (vm.js:56:10)\r
    6:43:18 PM yoga-dev-1:     at Object.runInThisContext (vm.js:97:10)\r
    6:43:18 PM yoga-dev-1:     at Module._compile (module.js:542:28)\r
    6:43:18 PM yoga-dev-1:     at Object.Module._extensions..js (module.js:579:10)\r
    6:43:18 PM yoga-dev-1:     at Module.load (module.js:487:32)\r
    6:43:18 PM yoga-dev-1:     at tryModuleLoad (module.js:446:12)\r
    6:43:18 PM yoga-dev-1:     at Function.Module._load (module.js:438:3)\r
    6:43:18 PM yoga-dev-1:     at Module.require (module.js:497:17)\r
    6:43:18 PM yoga-dev-1:     at module.js:669:12\r
    6:43:18 PM yoga-dev-1:     at Array.forEach (native)\r
    6:43:18 PM yoga-dev-1: C:\Program Files (x86)\SiteExtensions\Kudu\100.50331.6204\bin\Scripts\starter.cmd "C:\Program Files (x86)\SiteExtensions\Kudu\100.50331.6204\bin
    6:43:18 PM yogabandy-dev-1: ode_modules\.bin\kuduscript.cmd" -y --no-dot-deployment -r "C:\local\Temp\zipdeploy\extracted" -o "C:\home\site\deployments\tools" --basic --sitePath "C:\local\Temp\zipdeploy\extracted"
    6:43:19 PM yoga-dev-1: Deployment Failed.
    6:43:29 PM yoga-dev-1: Deployment failed.

UPDATE - Looking at my notes, on April 8, 2022 I had an issue with VS Code 1.66.1 where I was experiencing the same issue with failures in my web app deployment. So I downgraded to VS Code 1.65.2 and it worked again.

QUESTION - Is there something I can look into to see if there is some compatibility issue between VS Code, Azure and the web app I'm deploying? I checked the web app service and it's using .Net 6 as is my application. I rebooted my Mac, restarted VS Code. Not sure what else I can do to see if resetting something might help!

VonC

As I commented, the version of Node.js used by Azure during the deployment process may be different from the one you are using locally.

Azure uses the version specified in the WEBSITE_NODE_DEFAULT_VERSION app setting, the node property in the engines section of the package.json file, or a default version if neither of these are provided.

  • Make sure that a version of Node.js that supports the spread operator (5.12.0 or later) is being used during deployment.
  • Set the WEBSITE_NODE_DEFAULT_VERSION app setting in the Azure portal or specify the node version in the engines section of your package.json file.

The OP confirms:

I updated WEBSITE_NODE_DEFAULT_VERSION in Azure application setting from 6.9.1 to 18 (node version I'm using), and now I can deploy successfully again.


The engines field in package.json is not mandatory, and if it's not present, Azure will use the version specified in the WEBSITE_NODE_DEFAULT_VERSION app setting.
However, specifying the Node.js version in package.json can be useful to ensure that your application is always run with a compatible version of Node.js, regardless of the environment it's deployed in.

The engines field in package.json specifies the version of Node.js that your project is compatible with. It is usually found at the root level of the package.json file.
If it's not present, you can add it manually.

That would be something like:

{
  "name": "your-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "engines": {
    "node": "16.x"
  }
}

In this example, the engines field specifies that the project should be run with Node.js version 16.x. You can replace "16.x" with the version of Node.js that you are using.

The "*" value in your package-lock.json file means that your application should work with any version of Node.js. The package-lock.json file is generated automatically and should not be edited manually. Instead, any changes to the Node.js version should be made in the package.json file, and the package-lock.json file will be updated automatically the next time you run npm install.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Create-React-App build - "Uncaught SyntaxError: Unexpected token <"

jQuery after() Uncaught SyntaxError: Unexpected token ILLEGAL

Uncaught SyntaxError: Unexpected token & in javascript django app

Azure Web App Code Not Updating After Publish Until Restart (VS2017)

(update solution)Express web app service is throwing "SyntaxError: Unexpected token >"

No Deployment Option under Deployment found in Azure Web App Service

vue-cli-service: SyntaxError: Unexpected token '...'. Expected a property name

Heroku create-react-app deploy Uncaught SyntaxError: Unexpected token <

SyntaxError: Unexpected token { when compiling my node.js code

Azure YAML Deployment failing with "Error: Failed to deploy web package to App Service. Conflict (CODE: 409)"

Uncaught SyntaxError: Unexpected token '<' | after "yarn add xlsx" | React Typescript

Import profile VS Select existing - deployment in Azure app service

Getting "SyntaxError: Unexpected token '/' in...index.ejs while compiling ejs" error after updating npm packages

where to get deployment logs of azure app service VS-Code extension

Firebase deployed react app not working. Uncaught SyntaxError: Unexpected token '<'

Firefox vs chrome uncaught syntaxerror unexpected token error

What is causing an "Uncaught SyntaxError: Unexpected token ." in my app?

"Uncaught SyntaxError: Unexpected token <" in really basic code

AngularJS $http get service 'SyntaxError: Unexpected token }' issue

Azure Service Fabric Resource Deployment Failure Exit Code -532462766

Uncaught SyntaxError: Unexpected token ; after deploying to heroku in application.js

JavaScript Firebase Database web Uncaught SyntaxError: Unexpected token with no reason

SyntaxError: Unexpected token < in JSON at position 0 - React app in Rails API

Web app deployment failure with zip deployment?

Web2py project deployment on Azure app service

webpack gives me error at my config file at the plugins part saying that "plugins: [ SyntaxError: Unexpected token ':'"

--Expected token ':'-- in my VS Code, but --Uncaught SyntaxError: Unexpected token 'return'-- on my browser

Azure App Service: Deployment Source missing options [radio vs dropdown]

Azure web app not updating after successful deployment