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)
...
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.
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.
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' .
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.
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 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With