Cannot find module 'actions-on-google'

那年仲夏 提交于 2020-01-06 02:43:26

问题


I was going through google's tutorial for their action, while trying to make some modifications to suit what I was trying to do. When I run the terminal command 'firebase deploy', after a bit of processing my terminal will say: "Error parsing triggers: Cannot find module 'actions-on-google'. Try running npm-install in your functions directory before deploying.

I have run npm-install in the functions directory, but have had no luck in getting this to work.

Here is the top bit of code in my index.js file:

'use strict';

process.env.DEBUG = 'actions-on-google:*';
const {DialogflowApp} = require('actions-on-google');
const functions = require('firebase-functions');

exports.echoNumber = functions.https.onRequest((req, res) => {
  const app = new DialogflowApp({request: req, response: res});

回答1:


You should have a package.json file in that directory. It should have a dependencies section. And in that section there should be a line for every package that you require().

In particular

"actions-on-google": "^1.8.0",




回答2:


When this happened to me it was because I was trying to run the command from the base directory instead of the functions directory.




回答3:


Please try the below command in your Project/functions directory before deploy

npm install firebase-admin@5.5.0

npm install

It will work properly




回答4:


After exhausting the other answers, this worked for me

  1. Delete the functions/node_modules folder
  2. Using command prompt run npm install on the functions folder

My best guess is a corrupted functions/node_modules/actions-on-google folder




回答5:


Try to run the commands following in sequence:

  1. npm install action on google
  2. npm install

This worked for me might be useful for you too.



来源:https://stackoverflow.com/questions/48574726/cannot-find-module-actions-on-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!