Michel Michel - 19 days ago 5
Javascript Question

HTTP_USER_AGENT / Node.js

I have a little web site working with

Node.js
, and I need to do some tuning for mobiles.
For this I would like to access the
HTTP_USER_AGENT
. How can I do that?

I have read a few things on the net, but didn't come to a working solution at this point.
One of the thing I went through is this https://www.npmjs.com/package/useragent.

But as soon as I start, adding this to my code:

var useragent = require('useragent');


I get this error when looking at the site:

Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.


The log says:

Error: Cannot find module 'useragent'


I must obviously not be doing the right thing or doing it wrong.

Any suggestion will be much appreciated.

Answer

Did you installed your package first ?

npm install --save useragent

Regards

Comments