从bitbucket的Node.js应用程序azure色的部署

当我尝试从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" 

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

是因为我用过的节点模块吗?

还是在加载模块时出现问题?

看来你的package.json不是一个有效的JSON。


更新:

Kudu使用以下代码来读取package.json文件,请参阅selectNodeVersion.js的第179行。

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

因此,在将package.json推送到github之前,可以使用下面的代码来validation本地文件:

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

例如,我在上面提供的package.json的第38行添加了一个} ,我会得到和你一样的错误:

在这里输入图像说明

或者你可以使用命令npm install来检查它:

在这里输入图像说明