Comments (25)
Hi @lulucious,
Yes, If you have installed v1.0.0 then the usage is:
var Nexmo = require('nexmo');
var nexmo = new Nexmo(...);
These quick start examples should help:
https://github.com/nexmo-community/nexmo-node-quickstart
If they don't, could you please provide some example code? Or a repo that demonstrates the problem would be great too.
Thanks.
from vonage-node-sdk.
well this is EXACTLY what I did...
Do you confirm that : applicationId, privateKey and options are not mandatory?
Are you sure npm install nexmo is pointing to the right release?
By the way there is an extra } in your readme file :
var nexmo = new Nexmo({
apiKey: API_KEY,
apiSecret: API_SECRET,
applicationId: APP_ID,
privateKey: PRIVATE_KEY_PATH,
}, options });
from vonage-node-sdk.
Do you confirm that : applicationId, privateKey and options are not mandatory?
Yes, I can confirm that applicationId
and privateKey
are not mandatory.
Are you sure npm install nexmo is pointing to the right release?
https://www.npmjs.com/package/nexmo
Is correctly pointing to 1.0.0.
If you run:
git clone [email protected]:nexmo-community/nexmo-node-quickstart.git
cd nexmo-node-quickstart
mv .env-example .env
And populate the values in the .env
with the EXAMPLE_FROM_NUMBER
being a virtual number you are renting from Nexmo and EXAMPLE_TO_NUMBER
your number. Then run:
node sms/send.js
You phone should receive an SMS. I've just tested this.
If you look at sms/send.js
you'll see it uses the constructor without the applicationId
and privateKey
:
var Nexmo = require('nexmo');
var nexmo = new Nexmo({apiKey: API_KEY, apiSecret: API_SECRET}, {debug:true});
nexmo.message.sendSms(FROM_NUMBER, TO_NUMBER, 'Hello from Nexmo!');
I hope this helps.
from vonage-node-sdk.
Ok I found the problem, but I can't explain it easily...
the presence of this line in the file that requires nexmo breaks my call to the module :
body.match(/â|ê|î|ô|û|ë|ï|ç|ù/g)? then 'unicode' else 'text'
Any idea?
from vonage-node-sdk.
@lulucious can you provide any more context? Could you provide a code sample that reproduces the problem?
from vonage-node-sdk.
If a special caracter, or a single quote (’) is in your js file (even in a commented line!!), Node cannot compile the nexmo module...
from vonage-node-sdk.
@lulucious I'm not sure this is the issue. See https://github.com/cbetta/node-nexmo-unicode-example for proof that this works fine.
Did you actually put nexmo in your package.json
?
from vonage-node-sdk.
yes of course! I really did a lot of investigation before finding the
guilty lines...
This only worked when I removed that line and the one with the slanted
quote.
Even commenting the line did not help. Only removing it did. I can't
explain and i agree that it sounds unrelated but it is the case...
from vonage-node-sdk.
Just add on line 2 :
nexmo = new Nexmo({
apiKey: "yyy",
apiSecret: "xxx"
}, {
debug: true
});
from vonage-node-sdk.
@lulucious still works for me https://github.com/cbetta/node-nexmo-unicode-example (updated with your code)
from vonage-node-sdk.
@lulucious you have a typo on line 1, it needs to be var Nexmo
with a capital N
from vonage-node-sdk.
Hmm.. it is working when i run it in js but not with coffeescript
This is ok :
Nexmo = require('nexmo');
nexmo = new Nexmo({
apiKey: "ii",
apiSecret: "hh"
}, {
debug: true
});
body = "";
body = body.replace(/’/g, "'");
console.log("ok");
But this is not :
Nexmo = require('nexmo')
nexmo = new Nexmo({apiKey:"ii", apiSecret:"hh"}, {debug:true})
body = ""
body = body.replace(/’/g,"'")
console.log "ok"
However, it only triggers a problem with nexmo module! weird...
from vonage-node-sdk.
@lulucious both of them work fine here in js
and coffee
. I'm 99% certain your error is just referring to the first line in the code due to a syntax error (incorrectly). I'm pretty sure it's not our library in this case. I'd like to close this issue until we can actually prove this to be an issue with our library because I can't see how it is.
You ok with that?
from vonage-node-sdk.
@lulucious FYI I ran this code below and it works fine here.
Nexmo = require('nexmo')
nexmo = new Nexmo({apiKey:"ii", apiSecret:"hh"}, {debug:true})
body = ""
body = body.replace(/’/g,"'")
console.log "ok"
from vonage-node-sdk.
@lulucious just to be sure: what NPM/Node versions are you running?
from vonage-node-sdk.
v4.4.3
from vonage-node-sdk.
that same code returns :
Nexmo = require('nexmo')
nexmo = new Nexmo({apiKey:"ii", apiSecret:"hh"}, {debug:true})
body = ""
body = body.replace(/’/g,"'")
console.log "ok"
ReferenceError: Nexmo is not defined
at new Nexmo (/home/ldmint/Public/node-nexmo-unicode-example-master/node_modules/nexmo/lib/Nexmo.js:77:25)
at Object.<anonymous> (/home/ldmint/Public/node-nexmo-unicode-example-master/app.coffee:2:13)
at Object.<anonymous> (/home/ldmint/Public/node-nexmo-unicode-example-master/app.coffee:1:1)
at Module._compile (module.js:460:26)
at Object.exports.run (/home/ldmint/.nvm/versions/node/v0.12.7/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:134:23)
at compileScript (/home/ldmint/.nvm/versions/node/v0.12.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
at compilePath (/home/ldmint/.nvm/versions/node/v0.12.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
at Object.exports.run (/home/ldmint/.nvm/versions/node/v0.12.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
at Object.<anonymous> (/home/ldmint/.nvm/versions/node/v0.12.7/lib/node_modules/coffee-script/bin/coffee:7:41)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
from vonage-node-sdk.
@lulucious can you make me a project with package.json and everything like I did with https://github.com/cbetta/node-nexmo-unicode-example that shows it not working?
from vonage-node-sdk.
@lulucious tested in Node 4.4.3 and it all works fine here. Both coffeescript and Node.
from vonage-node-sdk.
FYI I am running CoffeeScript version 1.11.1
from vonage-node-sdk.
try running coffee app.coffee
https://github.com/lulucious/nexmo-weird-pb
from vonage-node-sdk.
@lulucious I'll get back to this later tonight.
from vonage-node-sdk.
@lulucious I tried your code and it all still works pretty fine for me. Both the Node and the Coffee version. There's something on your system definitely wrong.
from vonage-node-sdk.
@lulucious could you try a different Node version on your machine for me? Just want to see if that makes it go away.
from vonage-node-sdk.
Closing due to inactvity
from vonage-node-sdk.
Related Issues (20)
- Request timeout option is still broken HOT 1
- Cannot send Whatsapp auth template message HOT 4
- readme example does not compile in TS HOT 2
- Messages CLI not working HOT 3
- Vonage.sms.verifySignature doesn't work with inbound SMS message HOT 3
- [Bug]: Issue with npm install HOT 1
- [Bug]: Error: secretOrPrivateKey must be an asymmetric key when using RS256 HOT 8
- [Bug]: typescript results in vetch missing @types/node-fetch HOT 1
- How Do I: send this whatsapp template HOT 3
- [Bug]: getOwnedNumbers seems to return string (JSON) and not an object HOT 3
- [Bug]: vonage video createSession returns undefined sessionId HOT 4
- How Do I: transfer call HOT 2
- How Do I: connect 2 real phones? HOT 2
- Action Required: Fix Mend Configuration File - .whitesource - autoclosed HOT 1
- Action Required: Fix Mend Configuration File - .whitesource
- [Bug]: compability issue with node-fetch v3 HOT 4
- [Bug]: many deprecations when installed HOT 1
- [Bug]: Can not link vonage application with my VR phone number HOT 6
- [Bug]: Differences between documentation and implementation HOT 4
- [Bug]: voice.playTTS: TypeError: instanceof called on an object with an invalid prototype property. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vonage-node-sdk.