I am trying to have a simple js trigger use and external npm module
The module has this bit of js in it
exports.printMsg = function() {
console.log("This is a message from the demo package");
}
exports.myDateTime = function () {
console.log("hello from myDateTime");
return Date();
};
Using a basic package.json
{
"name": "first_mongo_module",
"version": "1.0.1",
"description": "my first try",
"main": "myFirstModule.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "my.name@gmail.com",
"license": "ISC",
"keywords": [],
"dependencies": {
"first_mongo_module": "^1.0.1"
}
}
I ran the npm tools to create and then publish the package for public access
Used the GUI to import the dependency successfully and it show the newest version.
Inside the trigger
I have this simple js
exports = function(changeEvent) {
const msg = require('first_mongo_module');
msg.printMsg();
}
When the trigger fires I get an Error: Cannot find module ‘first_mongo_module’
Something simple must be missing.
BTW running this on a free tier on Azure, and the same simple module works using node.
Thanks in advance for any help or pointers.