I have a node project inside another node project. When I open the root project in VS Code, node modules give me the error Cannot find module or its corresponding type declarations.
. But if I open the child node project I don’t get this error anymore. Any help regarding this?
Didn’t find any leads so far. Any help would be appreciated
2
Answers
Open your first project in first folder. Open your second project in its inside folser.
Or merge their files and make them one project.
There is a reason why they are in seperated folder. smh.
It appears that the module
axios
doesn’t exist yet. To install it with npm, writenpm install axios
in the terminal. In addition, it’s generally considered good practice to import with single quotes instead of double quotes. Thus,index.js
should be modified like so:import axios from "axios"
If the issue is not resolved, delete
node_modules
andpackage-lock.json
and reinstall your packages like so:Lastly, verify that the
"axios"
package is under the"dependencies"
object.This should resolve your issue.