Node.js 如何在DialogFlow中的Package.json文件中添加新的依赖项?

Node.js 如何在DialogFlow中的Package.json文件中添加新的依赖项?,node.js,json,dialogflow-es,Node.js,Json,Dialogflow Es,我刚刚开始创建一个聊天机器人,我希望它是多语言的。因此,我使用的是i18n模块。我在package.json中添加了它的依赖项,但现在它显示了一个错误: The deployment of your Cloud Function failed: Build failed: Build error details not available 这是我的package.json文件: [{ "name": "dialogflowFirebaseFulfillment", "descripti

我刚刚开始创建一个聊天机器人,我希望它是多语言的。因此,我使用的是i18n模块。我在package.json中添加了它的依赖项,但现在它显示了一个错误:

The deployment of your Cloud Function failed:
Build failed: Build error details not available
这是我的package.json文件:

[{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "8"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^2.2.0",
    "firebase-admin": "^5.13.1",
    "firebase-functions": "^2.0.2",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0"
  }
},
 {
  "name": "i18n",
  "description": "lightweight translation module with dynamic json storage",
  "version": "0.8.4",
  "homepage": "http://github.com/mashpie/i18n-node",
  "repository": {
    "type": "git",
    "url": "http://github.com/mashpie/i18n-node.git"
  },
  "author": "Marcus Spiegel <marcus.spiegel@gmail.com>",
  "main": "./index",
  "keywords": [
    "template",
    "i18n",
    "l10n"
  ],
  "directories": {
    "lib": "."
  },
  "dependencies": {
    "debug": "*",
    "make-plural": "^6.0.1",
    "math-interval-parser": "^2.0.1",
    "messageformat": "^2.3.0",
    "mustache": "*",
    "sprintf-js": "^1.1.2"
  },
  "devDependencies": {
    "async": "^3.1.0",
    "cookie-parser": "^1.4.4",
    "express": "^4.16.4",
    "jshint": "*",
    "mocha": "^6.2.2",
    "should": "*",
    "sinon": "*",
    "url": "^0.11.0",
    "zombie": "*"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "jshint": "jshint --verbose .",
    "test": "npm run jshint && mocha --exit",
    "test-ci": "npm run jshint && istanbul cover mocha -- --exit"
  },
  "license": "MIT"
}]
[{
“名称”:“dialogflowFirebaseFulfillment”,
“说明”:“这是Dialogflow代理使用Firebase云功能的默认实现方式”,
“版本”:“0.0.1”,
“私人”:没错,
“许可证”:“Apache 2.0版”,
“作者”:“谷歌公司”,
“发动机”:{
“节点”:“8”
},
“脚本”:{
“开始”:“firebase服务--仅功能:dialogflowFirebaseFulfillment”,
“部署”:“firebase部署--仅功能:dialogflowFirebaseFulfillment”
},
“依赖项”:{
“谷歌行动”:“^2.2.0”,
“firebase管理员”:“^5.13.1”,
“firebase功能”:“^2.0.2”,
“dialogflow”:“^0.6.0”,
dialogflow实现“^0.5.0”
}
},
{
“名称”:“i18n”,
“说明”:“具有动态json存储的轻量级翻译模块”,
“版本”:“0.8.4”,
“主页”:http://github.com/mashpie/i18n-node",
“存储库”:{
“类型”:“git”,
“url”:”http://github.com/mashpie/i18n-node.git"
},
“作者”:“马库斯·斯皮格尔”,
“主”:“/index”,
“关键词”:[
“模板”,
“i18n”,
“l10n”
],
“目录”:{
“lib”:”
},
“依赖项”:{
“调试”:“*”,
“复数”:“^6.0.1”,
“数学间隔分析器”:“^2.0.1”,
“messageformat”:“^2.3.0”,
“胡须”:“*”,
“sprintf js”:“^1.1.2”
},
“依赖性”:{
“异步”:“^3.1.0”,
“cookie解析器”:“^1.4.4”,
“快车”:“^4.16.4”,
“jshint”:“*”,
“摩卡咖啡”:“^6.2.2”,
“应”:“*”,
“信农”:“*”,
“url”:“^0.11.0”,
“僵尸”:“*”
},
“发动机”:{
“节点”:“>=0.10.0”
},
“脚本”:{
“jshint”:“jshint--verbose.”,
“测试”:“npm运行jshint&&mocha——退出”,
“测试ci”:“npm运行jshint和伊斯坦布尔覆盖摩卡----退出”
},
“许可证”:“麻省理工”
}]
这是我的index.js文件:

// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const i18n= require('i18n');

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

i18n.configure({
    locales : ['en-IN','hi-IN-1'],
    directory : '',
    defaultLocale : 'en-IN'
});

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

  function welcome(agent) {
    agent.add(`Welcome to my agent!`);
  }

  function fallback(agent) {
    agent.add(`I didn't understand`);
    agent.add(`I'm sorry, can you try again?`);
  }

  function About(agent){
    agent.add(`We are a company!`);
  }

  // // Uncomment and edit to make your own intent handler
  // // uncomment `intentMap.set('your intent name here', yourFunctionHandler);`
  // // below to get this function to be run when a Dialogflow intent is matched
  // function yourFunctionHandler(agent) {
  //   agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
  //   agent.add(new Card({
  //       title: `Title: this is a card title`,
  //       imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
  //       text: `This is the body text of a card.  You can even use line\n  breaks and emoji! You appear to be using multiple objects in a list inside your package.json file, I'm not sure if this is how package.json files are meant to work.

[{

},{

}]
//请参见https://github.com/dialogflow/dialogflow-fulfillment-nodejs
//用于Dialogflow履行库文档、示例和报告问题
"严格使用",;
const functions=require('firebase-functions');
const{WebhookClient}=require('dialogflow-fulfillment');
const{Card,Suggestion}=require('dialogflow-fulfillment');
常量i18n=需要('i18n');
process.env.DEBUG='dialogflow:DEBUG';//启用lib调试语句
i18n.configure({
地区:['en-IN','hi-IN-1'],
目录:“”,
defaultLocale:'en-IN'
});
exports.dialogflowFirebaseFulfillment=functions.https.onRequest((请求,响应)=>{
const-agent=new-WebhookClient({request,response});
log('Dialogflow请求头:'+JSON.stringify(Request.headers));
log('Dialogflow请求主体:'+JSON.stringify(Request.body));
功能欢迎(代理){
agent.add(`Welcometomyagent!`);
}
功能回退(代理){
agent.add(`我不明白');
agent.add(`对不起,你能再试一次吗?`);
}
关于(代理)的功能{
agent.add(`我们是一家公司!`);
}
////取消注释并编辑以生成自己的意图处理程序
////取消对“intentMap.set”的注释(“此处为您的意图名称”,yourFunctionHandler)`
////在下面获取当Dialogflow意图匹配时要运行的函数
//函数处理程序(代理){
//add(`此消息来自Dialogflow的Firebase editor云函数!`);
//代理。添加(新卡)({
//标题:`title:这是一张卡片的标题`,
//imageUrl:'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',

//text:`这是卡片的正文。您甚至可以使用换行符和表情符号!如果您在package.json文件中的列表中使用了多个对象,我不确定package.json文件是否就是这样工作的

{

}
你能把你所有的部分压缩成一个物体吗

"dependencies": {
  "actions-on-google": "^2.2.0",
  "firebase-admin": "^5.13.1",
  "firebase-functions": "^2.0.2",
  "dialogflow": "^0.6.0",
  "dialogflow-fulfillment": "^0.5.0",
  "i18n" : "^0.8.4"
}

例如,将依赖项移动到单个部分等。

您可以将npm包:i18n添加到package.json中的依赖项对象中,如下所示:


你说的是:
{{},{}}
?因为它也显示了错误。如果你说的是其他内容,请告诉我。你目前有[{},{}]。你能试一下吗?{}相反,我觉得你试图在一个包中声明2个package.json内容。json