On Nov 28, 2014, at 5:28 PM, Christian Nwamba wrote:

> Hi i am trying to include angular to my index.html but i get the error: path 
> must be absolute or specify root to res.sendFile.

This is an express-specific question. You may get better advice about express 
questions on the express-js google group instead of on this general nodejs 
google group.

>     app.get('*', function(req, res){
>       res.sendFile('./public/index.html')
>     })

This is the res.sendFile it's talking about. As it says in the error message, 
and in the express documentation...

http://expressjs.com/api.html#res.sendFile

"Unless the root option is set in the options object, path must be an absolute 
path of the file."

So either make it absolute:

        res.sendFile(path.join(__dirname, 'public', index.html'))

Or use the options object to specify the root:

        res.sendFile('index.html', {root: path.join(__dirname, 'public')})

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/170A3AE8-7F87-4537-95C7-DF997EFC4221%40ryandesign.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to