Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: need help with node trobleshooting

  1. #1
    Join Date
    Apr 2024
    Beans
    4

    Unhappy need help with node trobleshooting

    Hi ,
    i'm developing a mysql, node, angular, express project.
    the problem is everytime i create a new API it is giving 404 error in postman.
    i use xampp for mysql for the stack im developing. Any troubleshooting steps are welcomed as im new to ubuntu.
    Regards,
    Gowri Shankar

  2. #2
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: need help with node trobleshooting

    I'm going through node/npm upgrade right now. So we can sync. Run these.

    node --version


    npm --version

  3. #3
    Join Date
    Apr 2024
    Beans
    4

    Re: need help with node trobleshooting

    kuber@kuber:~/sidgptproject/sidgptangular/backend$ node --version
    v18.20.1
    kuber@kuber:~/sidgptproject/sidgptangular/backend$ npm --version
    10.5.0
    kuber@kuber:~/sidgptproject/sidgptangular/backend$

  4. #4
    Join Date
    Apr 2024
    Beans
    4

    Re: need help with node trobleshooting

    Quote Originally Posted by dragonfly41 View Post
    I'm going through node/npm upgrade right now. So we can sync. Run these.

    node --version


    npm --version
    kuber@kuber:~/sidgptproject/sidgptangular/backend$ node --version
    v18.20.1
    kuber@kuber:~/sidgptproject/sidgptangular/backend$ npm --version
    10.5.0
    kuber@kuber:~/sidgptproject/sidgptangular/backend$

  5. #5
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: need help with node trobleshooting

    I have v 18.0.0 and am going through upgrade process to 20 required by an app (different from yours).
    Encountered errors, and following advice ran:
    which -a node
    found had two versions of node installed.
    /usr/bin/node
    /bin/node


    Next step to clear out and reinstall node.
    Last edited by dragonfly41; 1 Week Ago at 07:20 PM.

  6. #6
    Join Date
    Apr 2024
    Beans
    4

    Re: need help with node trobleshooting

    Quote Originally Posted by dragonfly41 View Post
    I have v 18.0.0 and am going through upgrade process to 20 required by an app (different from yours).
    Encountered errors, and following advice ran:
    which -a node
    found had two versions of node installed.
    /usr/bin/node
    /bin/node


    Next step to clear out and reinstall node.
    but i found only one installation

    kuber@kuber:~/sidgptproject/sidgptangular/backend$ which -a node
    /home/kuber/.nvm/versions/node/v18.20.1/bin/node
    kuber@kuber:~/sidgptproject/sidgptangular/backend$
    Last edited by shan2edward; 1 Week Ago at 07:27 PM. Reason: the bb made response look bad

  7. #7
    Join Date
    Aug 2016
    Location
    Wandering
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: need help with node trobleshooting

    Just driving by but I also see what you found dragonfly41
    Code:
    which -a node
    /usr/bin/node
    /bin/node
    Code:
    node --version
    v18.19.1
    Apologies for any confusion
    With realization of one's own potential and self-confidence in one's ability, one can build a better world.
    Dalai Lama>>
    Code Tags | System-info | Forum Guide lines | Arch Linux, Debian Unstable, FreeBSD

  8. #8
    Join Date
    Dec 2014
    Beans
    2,603

    Re: need help with node trobleshooting

    It's not a problem, it's the exact same file since /bin/ is a symlink to /usr/bin these days.

    Holger

  9. #9
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: need help with node trobleshooting

    The issue I have is bumping up to v 20.

    Errors were encountered while processing:
    /var/cache/apt/archives/nodejs_20.12.2-1nodesource1_amd64.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

  10. #10
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: need help with node trobleshooting

    Switching to OP's parallel issues (lest I be accused of highjacking) here is what my Sherlock Holmes agent comes up with:

    [PROMPT] Concurrent with this session another party reports: i'm developing a mysql, node, angular, express project.the problem is everytime i create a new AP...

    ANSWER | PHIND-70B MODEL


    When developing a MySQL, Node, Angular, Express project and encountering a 404 error for new APIs in Postman, there are several areas to investigate and potential solutions to apply. This issue typically arises from misconfigurations in the Express server setup, incorrect API endpoint definitions, or issues with the server's routing. Here's a parallel approach to troubleshoot and resolve the issue:

    1. Check API Endpoint Definitions


    Ensure that the API endpoints you're trying to access are correctly defined in your Express application. This includes verifying the HTTP method (GET, POST, PUT, DELETE, etc.) and the route path. A common mistake is a typo in the route path or using the wrong HTTP method.

    2. Verify Express Server Configuration



    • Middleware Configuration: Ensure that your Express server is correctly configured to use middleware for parsing JSON payloads (express.json()) and handling CORS if your API is being accessed from a different origin. This is crucial for APIs that will be consumed by a frontend application like Angular 4.



    • Error Handling Middleware: Implement or verify the presence of error handling middleware in your Express application. This middleware should catch any requests to undefined routes and return a 404 error with a custom message, such as "Endpoint Not Found" 4.


    3. Review Express Routes



    • Route Definitions: Double-check your route definitions in Express to ensure they match the endpoints you're trying to access. This includes the correct use of app.get(), app.post(), etc., and the correct path specified 4.



    • Route Order: The order in which routes are defined in Express matters. Ensure that your catch-all 404 middleware is placed after all your API route definitions. If it's placed before, it might catch requests to valid routes, leading to false 404 errors 4.


    4. Check for Typos



    • Endpoint Paths: A common cause of 404 errors is a simple typo in the endpoint path. Double-check the paths you're using in Postman against those defined in your Express application.



    • HTTP Methods: Ensure that you're using the correct HTTP method (GET, POST, etc.) in Postman that matches the method defined in your Express route.


    5. Server Running and Port



    • Server Status: Ensure that your Express server is running. You can check this by looking at the console output when you start your server.



    • Port Configuration: Verify that the port your Express server is listening on matches the port you're using in Postman. If you're using environment variables to configure the port, ensure that the .env file is correctly set up and loaded into your application 4.


    6. CORS Configuration


    If your Angular application is served from a different origin (domain, protocol, or port) than your Express API, ensure that you have correctly configured CORS in your Express application. This is crucial for allowing your Angular application to make requests to your Express API 4.

    7. Debugging



    • Logging: Add console logs in your Express route handlers to ensure that the requests are reaching your server and to help identify where the request might be failing.



    • Postman Console: Use the Postman console to inspect the details of the request and response. This can provide clues about what might be going wrong.


    By systematically checking these areas, you should be able to identify and resolve the issue causing the 404 errors for your new APIs in Postman.




Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •