简体   繁体   English

从bitbucket部署node.js应用程序进行Azure部署

[英]node.js app azure deployment from bitbucket

I am getting following error when i try to deploy nodejs app from bitbucket. 当我尝试从bitbucket部署nodejs应用程序时,出现以下错误。

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 使用节点6.9.1

package.json 的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. 看来您的package.json不是有效的JSON。


Update: 更新:

Kudu uses the following code to read the package.json file, see line 179 of selectNodeVersion.js . Kudu使用以下代码读取package.json文件,请参见selectNodeVersion.js的第179行。

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: 因此,在将package.json推送到github之前,可以使用下面的代码在本地验证文件:

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: 例如,我在上面提供的package.json中的第38行添加了一个} ,将得到与您相同的错误:

在此处输入图片说明

Or you can just use the command npm install to check it: 或者,您可以只使用命令npm install来检查它:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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