[英]How to install npm packages within Google Dialogflow Fullfilment Inline Editor
I would like to install some npm packages into my chatbot but I cant make this working.我想在我的聊天机器人中安装一些 npm 包,但我无法使其正常工作。
package.json file looks as below: 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": "~6.0"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^1.5.x",
"firebase-admin": "^4.2.1",
"firebase-functions": "^0.5.7",
"apiai": "^4.0.3"
}
}
In index.js I have:在 index.js 我有:
var jsonQuery = require('json-query');
The logs says: dialogflowFirebaseFulfillment Function load error: Code in file index.js can't be loaded.日志显示:dialogflowFirebaseFulfillment 函数加载错误:无法加载文件 index.js 中的代码。 Did you list all required modules in the package.json
您是否在 package.json 中列出了所有必需的模块
Any idea?有什么想法吗?
The error arrived because you didn't include package 'json-query'出现错误是因为您没有包含包“json-query”
run below command after all working fine.在所有工作正常后运行以下命令。
npm install json-query
Answer is simpler than you would think (and @Dhaval mentioned it).答案比您想象的要简单(@Dhaval 也提到了)。 You only have to include the name of the npm package in
package.json
:你只需要在
package.json
包含 npm 包的名称:
{
"some": "crazyPropsFoo",
"engines": {},
"scripts": {},
"dependencies": {
"actions-on-google": "^1.5.x",
"firebase-admin": "~4.1.2",
"firebase-functions": "~0.5",
"npmpackage": "1.8.0", //Here it is
"apiai": "^4.0.3"
}
}
Then require
that package in your index.js
file:然后
require
该包在你的index.js
文件:
var PackageObj = require("npmpackage").PackageObject;
var yourVar = new PackageObj();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.