Code Monkey home page Code Monkey logo

Comments (25)

leggetter avatar leggetter commented on July 28, 2024

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.

derhyl avatar derhyl commented on July 28, 2024

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.

leggetter avatar leggetter commented on July 28, 2024

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.

derhyl avatar derhyl commented on July 28, 2024

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.

leggetter avatar leggetter commented on July 28, 2024

@lulucious can you provide any more context? Could you provide a code sample that reproduces the problem?

from vonage-node-sdk.

derhyl avatar derhyl commented on July 28, 2024

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.

cbetta avatar cbetta commented on July 28, 2024

@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.

derhyl avatar derhyl commented on July 28, 2024

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.

derhyl avatar derhyl commented on July 28, 2024

Just add on line 2 :

nexmo = new Nexmo({
apiKey: "yyy",
apiSecret: "xxx"
}, {
debug: true
});

from vonage-node-sdk.

cbetta avatar cbetta commented on July 28, 2024

@lulucious still works for me https://github.com/cbetta/node-nexmo-unicode-example (updated with your code)

from vonage-node-sdk.

cbetta avatar cbetta commented on July 28, 2024

@lulucious you have a typo on line 1, it needs to be var Nexmo with a capital N

from vonage-node-sdk.

derhyl avatar derhyl commented on July 28, 2024

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.

cbetta avatar cbetta commented on July 28, 2024

@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.

cbetta avatar cbetta commented on July 28, 2024

@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.

cbetta avatar cbetta commented on July 28, 2024

@lulucious just to be sure: what NPM/Node versions are you running?

from vonage-node-sdk.

derhyl avatar derhyl commented on July 28, 2024

v4.4.3

from vonage-node-sdk.

derhyl avatar derhyl commented on July 28, 2024

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.

cbetta avatar cbetta commented on July 28, 2024

@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.

cbetta avatar cbetta commented on July 28, 2024

@lulucious tested in Node 4.4.3 and it all works fine here. Both coffeescript and Node.

from vonage-node-sdk.

cbetta avatar cbetta commented on July 28, 2024

FYI I am running CoffeeScript version 1.11.1

from vonage-node-sdk.

derhyl avatar derhyl commented on July 28, 2024

try running coffee app.coffee
https://github.com/lulucious/nexmo-weird-pb

from vonage-node-sdk.

cbetta avatar cbetta commented on July 28, 2024

@lulucious I'll get back to this later tonight.

from vonage-node-sdk.

cbetta avatar cbetta commented on July 28, 2024

@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.

cbetta avatar cbetta commented on July 28, 2024

@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.

cbetta avatar cbetta commented on July 28, 2024

Closing due to inactvity

from vonage-node-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.