简体   繁体   中英

node.js app azure deployment from bitbucket

I am getting following error when i try to deploy nodejs app from bitbucket.

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling node.js deployment.
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
undefined:38
}
^
An error has occurred during web site deployment.
SyntaxError: Unexpected token } in JSON at position 1090
    at Object.parse (native)
    at Object.<anonymous> (D:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\selectNodeVersion.js:179:44)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
undefined:38\r\n}\r\n^\r\n\r\nSyntaxError: Unexpected token } in JSON at position 1090\r\n    at Object.parse (native)\r\n    at Object.<anonymous> (D:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\selectNodeVersion.js:179:44)\r\n    at Module._compile (module.js:570:32)\r\n    at Object.Module._extensions..js (module.js:579:10)\r\n    at Module.load (module.js:487:32)\r\n    at tryModuleLoad (module.js:446:12)\r\n    at Function.Module._load (module.js:438:3)\r\n    at Module.runMain (module.js:604:10)\r\n    at run (bootstrap_node.js:394:7)\r\n    at startup (bootstrap_node.js:149:9)\r\nD:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

Using node 6.9.1

package.json

{
      "name": "example",
      "version": "1.0.0",
      "description": "REST APIs for example",
      "main": "app.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "repository": {
        "type": "git",
        "url": "git+abc"
      },
      "author": "abc",
      "license": "ISC",
      "homepage": "abc#readme",
      "dependencies": {
        "azure-storage": "^2.1.0",
        "body-parser": "^1.17.1",
        "change-case": "^3.0.1",
        "dateformat": "^2.0.0",
        "dotenv": "^4.0.0",
        "express": "^4.15.2",
        "jsonwebtoken": "^7.3.0",
        "minimist": "^1.2.0",
        "morgan": "^1.8.1",
        "mssql": "^4.0.1",
        "multer": "^1.3.0",
        "nconf": "^0.8.4",
        "node-friendly-response": "^3.1.4",
        "request": "^2.81.0",
        "require-dir": "^0.3.1",
        "swagger-node-express": "^2.1.3",
        "tedious": "^2.0.0",
        "tedious-promises": "^0.4.1",
        "underscore": "^1.8.3",
        "winston": "^2.3.1"
      }
    }

Is it because of the node modules which i have used?

Or is it the problem during the loading of modules?

It seems that your package.json is not a valid JSON.


Update:

Kudu uses the following code to read the package.json file, see line 179 of selectNodeVersion.js .

json = existsSync(packageJson) && JSON.parse(fs.readFileSync(packageJson, 'utf8'));

So, before you push the package.json to github, you can use the code below to verify the file on your local:

var fs = require("fs");
var json = JSON.parse(fs.readFileSync("./package.json", 'utf8'));
console.log(json);

For example, I added one more } at line 38 in package.json your provided above, I would get the same error as yours:

在此处输入图片说明

Or you can just use the command npm install to check it:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM