I have downloaded a twilio node module into a local directory where my project is. But when I run the node file, it throws an error. Below the error here, I've outlined the directory.
The error:
gamacbook:twilioapp gattra$ node app.js
module.js:340
throw err;
^
Error: Cannot find module 'node_modules/twilio/lib'
My local directory is:
twilioApp
|_app.js
|_index.html
|_main.css
|_script.js
|_node_modules
|_twilio
|_lib
There are obviously a bunch of files in twilio
directory but i'm trying to access those in lib
.
My code is:
var accountSid = "removed";
var authToken = "removed";
var client = require('node_modules/twilio/lib')(accountSid, authToken);
app.get('/', function () {
client.messages.create({
body: "Today is awesome and you rock!",
to: phoneNumber,
from: "removed"
}, function (err, message) {
process.stdout.write(message.sid);
})
})
That's not how you should use modules in node. Simply:
var twilio = require('twilio')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.