skip to Main Content

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?

Package

Error

Didn’t find any leads so far. Any help would be appreciated

2

Answers


  1. 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.

    Login or Signup to reply.
  2. It appears that the module axios doesn’t exist yet. To install it with npm, write npm 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 and package-lock.json and reinstall your packages like so:

    Terminal:
    
    #  for macOS and Linux
    rm -rf node_modules
    rm -f package-lock.json
    rm -f yarn.lock
    
    # clean npm cache
    npm cache clean --force
    
    # install packages
    npm install
    
    -----
    
    # for Windows
    rd /s /q "node_modules"
    del package-lock.json
    del -f yarn.lock
    
    # clean npm cache
    npm cache clean --force
    
    # install packages
    npm install
    
    

    Lastly, verify that the "axios" package is under the "dependencies" object.

    This should resolve your issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search