问题
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
- Delete the
functions/node_modules folder
- 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:
npm install action on google
npm install
This worked for me might be useful for you too.
来源:https://stackoverflow.com/questions/48574726/cannot-find-module-actions-on-google