Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js: Cannot find module 'ico'

My website (running on the express framework) suddenly started complaining that it needed a favicon. Upon adding a favicon.ico, it now gives me this error every time someone tries to view a page.

Error: Cannot find module 'ico'
at Function._resolveFilename (module.js:334:11)
...
like image 271
ario Avatar asked Jan 29 '12 15:01

ario


People also ask

How do I resolve Cannot find module error using node JS?

To solve the "Cannot find module" error in Node. js, make sure to install the package from the error message if it's a third-party package, e.g. npm i somePackage . If you get the error with a local module, make sure to point the node command to a file that exists.

Can not find module node JS?

To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.

Can not find module node path?

To solve the "Cannot find module path or its corresponding type declarations" error, install the types for node by running the command npm i -D @types/node . You can then import path with the following line of code import * as path from 'path' .


2 Answers

Resolved; I have

app.all('/:action', function(req, res){

in my app.js, and it was trying to interpret the favicon.ico as a page.

like image 74
ario Avatar answered Nov 03 '22 00:11

ario


You just have to add a 'GET' handler for '/favico.ico' ;

app.get('/favico.ico' , function(req , res){/*code*/});

you could just add it there to silence the error or you could respond with an actual img uri .

like image 32
Ahmed Eid Avatar answered Nov 03 '22 00:11

Ahmed Eid