I am trying to link the Mandrill library into my node project.
I have backtracked it right upto the following code which "stops" the project. This code is from the mandril API documentation.
var mandrill = require('mandrill-api/mandrill');
var mandrill_client = new mandrill.Mandrill('My KEY');
I have installed the mandril api using npm install mandrill-api and I can see it my node_modules folder. However when I deploy the project to the server the application stops running. It clearly is not referencing properly but I don't see how.
The code is being called in config.js. I'm sure I'm making a stupid mistake.
Related
I'm new to the web developing stuff and currently watching on udemy a 70h course.
I like to practice new learned stuff in real world applications. Therefore I've setted up an httpd container (https://hub.docker.com/_/httpd) with a bootstrap template in it (https://startbootstrap.com/theme/sb-admin-2)
My question: how do I add new node.js modules to this template? I want to add a module to connect the website to my postgres database.
The volume I made for the httpd container is as follows: /usr/local/apache2/sb/src/:/usr/local/apache2/htdocs/
In this directory I have installed the postgres module via npm and wrote a simple javascript code in index.js. If I call index.js via node index.js from the terminal it works fine. If I try to call it from the website it doesnt work. I know I missed something important to get this module work but I can't figure it out.
Edit
It was a really simple example of using extern modules in node.js shown in udemy. I've tried to use this example in my website.
index.js
var superhero = require('superheroes');
var hero = superhero.random();
function testCall(){
// alert("just a test!");
alert(hero);
}
In index.html I call the "testCall" function as follows
<body id="page-top" onload="testCall()">
This part works well, If I put a simple string as alert, for instance "alert("just a test!");"
I want to build a dashboard to display some values stored in postgres
I'm using the meteor framework, and trying to use google sheets to visualize some of my app's data. But for whatever reason, I can't seem to get the google api to load. I started with the command npm i googleapis and adding const {google} = require('googleapis') Which is to my knowledge correct. However, when I console.log(google) it spits out undefined.
I'm running Meteor 1.8.1, Node 6.12.0, and googleapi ^39.2.0
I would love to know what I'm doing wrong, most other people with this issue needed to update various other packages, so I've already run npm update To no avail, I've tried using import { google } from 'googleapis' Also to no avail, I saw somewhere that that would require transformations or something, but it still spits out undefined
I noticed that if I run require('googleapis') from my meteor shell, then it returns all the methods and whatnot that it's supposed to.
Ok, how I do it, to prevent adding another NPM to my Meteor projects ...
In my main.html I have this line:
<link rel="dns-prefetch" href="//maps.googleapis.com">
The next example shows adding google maps. I first make sure that, in a session, I load this library maximum once.
I call this code in multiple pages as I need the API. Since I use react, I do i in 'componentDidMount'.
if (!(window.google && window.google.maps)) {
const script = document.createElement('script')
script.src = 'https://maps.googleapis.com/maps/api/js?key=xxxxxxxxx&libraries=places'
script.defer = true
document.head.appendChild(script)
}
Removing my node_modules and running npm i did the trick
I'm trying to set up my app script project using clasp and test it locally using gas-local, I have reached the step of testing but I got this error ReferenceError: SpreadsheetApp is not defined.
gas.js
//require gas-local itself
var gas = require('gas-local');
//require your downloaded google apps script library from src subfolder
var glib = gas.require('./src');
where src is my google app script project folder, however when I node gas I got the ReferenceError: SpreadsheetApp is not defined
The idea from using gas-local is that I want to know my GAS cloudProject ID programatically, so I thought I would trigger any method locally and get the project-id from the error message that will be thrown.
I would appreciate anyone writes a step by step guide with screenshots if possible showing how to accomplish this process.
I had already implemented authentication for the app I'm working on but am trying to refactor it based on a recent tutorial I did which I thought was very clear and also involved adding facebook / google / twitter auth which I would like to do.
So far, I've updated the user model and defined my local strategy for signup but when I go to try and run the app now, I'm getting an error. I have the app uploaded to github and wondered if somebody would be able to check it out and see where I'm going wrong. The error is pointing to a part of the index file until node_modules / express but I cannot work out what's up and I'd like to know before I proceed further.
Latest commit is under: https://github.com/DaveBage83/friendly-invention
Thanks!
A few things for you notice.
1 - Do not commit the node_modules folder. Once you have all your dependencies in the package.json file, the npm install will download all of for you again.
2 - This code is full of erros. I won't put everything here, I believe you find them by yourself. Otherwise, put the specific code here, so we can help you out.
About the question:
In you app.js file.
...
authRoutes = require('./routes/index')(app, passport)
...
If you look at the ./routes/index, you'll see that it is exporting a route object, witch does not expect the two parameters. (e.g. (app, passport)).
Hope it can still help you.
I'm running node on my vps server. node is at my root, my app.js with node_modules (express, socket.io) are in /home/vps/public_html/
when following github readme for setting up sendgrid i run into trouble:
config.js is not live by the sounds of it as when I run sendgrids simple code example if i
a.) refer to config.js by doing:
var sendgrid=new SendGrid(user,key);
node kills its self because user is not defined.
b.) bypass config.js by doing:
var sendgrid=new SendGrid({user:'my_user_name',key:'my_password'});
I get console.log(message) of [ 'Permission denied, wrong credentials' ]
here is another image this one is of my public_html structure:
does any one know how to activate this config.js?
Should I have installed node.js into my public_html in the beginning?
So, there are a few things wrong here:
1) We have a typo in the README (which has now been updated)
tl;dr - you should type npm test not make test
Essentially, you're typing make test and make is coming back and saying "Hey, there's no rule for test in the cwd. It doesn't look like there's anything for me to do. Bye!". If you look carefully, there is no Makefile in the node library, so there's obviously not going to be any rules. So make definitely won't work in this case. What the README should have said is npm test. NPM is the package manager for node and it has a helper method test which runs all the tests for a given module.
Also, just to be clear - when you're typing npm test, all you are doing is running the tests for the library. Really this should only be necessary if you're adding features or fixing bugs on the library itself. If you're trying to use the library to send email, you should read the section titled "Usage".
2) You have a typo in your code (which is why the other sample didn't work)
Your code looks like this:
var sendgrid = new SendGrid({user:'my_user_name', key:'my_password'});
The code sample that we provide looks like this:
var sendgrid = new SendGrid(user, key);
Notice the difference? You're passing in a javascript object and we're expecting two discrete string values instead. The library is interpreting that as your username is "{user:'my_user_name', key:'my_password'}" with no password (because you didn't provide a second parameter). Instead you should do the following:
var sendgrid = new SendGrid("my_user_name", "my_password");