Getting a 502 Bad Gateway when trying to install via NPM

Getting a 502 Bad Gateway when trying to install via NPM

hjohnsickhjohnsick Posts: 12Questions: 5Answers: 0

I'm trying to install datatables editor following the documentation here, https://editor.datatables.net/manual/installing/ under NPM package manager. I have included a .npmrc file in my root directory.
It contains the following,

@datatables.net:registry=https://npm.datatables.net/
//npm.datatables.net/:_authToken=${DATATABLES_NPM_TOKEN}

I stored the authToken in my .env file. I want to install with bootstrap 5. I ran this command,

npm install --save @datatables.net/editor-bs5

I received this error,
npm ERR! code E502
npm ERR! 502 Bad Gateway - GET https://npm.datatables.net/@datatables.net%2feditor-bs5

I also tried

npm install --save @datatables.net/editor-dt

and got this error
npm ERR! code E502
npm ERR! 502 Bad Gateway - GET https://npm.datatables.net/@datatables.net%2feditor-dt

Any ideas as to what the issue is?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 22,261Questions: 26Answers: 5,122

    According to the Mozilla 502 docs the error could be client side or server side. I can get to the URLs you posted above using a web browser but get an authorization error. What happens when you click on one of the URLs?

    I don't have NPM installed to try it. See if some of the steps here help you to troubleshoot to see if the issue is on your side.

    Kevin

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    I've just tried it and it seems to work no problem for me:

    $ npm install '@datatables.net/editor-dt'
    
    added 5 packages, and audited 6 packages in 2s
    
    found 0 vulnerabilities
    

    Possibly it was a blip in the network? Are you able to install it now?

    Allan

  • hjohnsickhjohnsick Posts: 12Questions: 5Answers: 0

    I'm still not able to install. When I put this into my browser https://npm.datatables.net/:_authToken=MyTokenIsHere I get {
    "error": "Invalid Authorization"
    } Is there an issue with my token? My token was prepopulated when viewing the documentation under NPM package manager -> Configure access.

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Hi,

    Thanks for the additional information. Could you try:

    npm install '@datatables.net/editor-dt@2.4.1'
    

    please? That looks like the newest version that your license currently has access to (upgrades included for a year after purchase).

    If that is what the problem is, I need to look into that, as a 502 is a horrible error for that!

    Allan

  • hjohnsickhjohnsick Posts: 12Questions: 5Answers: 0

    I just tried npm install '@datatables.net/editor-dt@2.4.1' and get the same error message.

    This is what my file structure looks like:

    I believe the .npmrc is in the correction location.

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    I'm sorry you are having problems with this! The idea is that it should make things easier...

    I've just tried it with basically the same as your setup - the .npmrc file in the same directory and this as the package.json file:

    {
      "name": "editor",
      "version": "1.0.0",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "description": "",
      "dependencies": {
        "@datatables.net/editor-dt": "^2.4.1"
      }
    }
    

    I've also used the access key for your account

    It installs no problem for me:

    $ npm install
    
    added 5 packages, and audited 6 packages in 2s
    
    found 0 vulnerabilities
    $
    

    Is it possible you are behind a proxy that is blocking the access to npm.datatables.net or something like that?

    What version of node and npm are you using? I've got this on the machine I tried for that test:

    $ node --version
    v20.15.1
    $ npm --version
    10.7.0
    

    Allan

  • hjohnsickhjohnsick Posts: 12Questions: 5Answers: 0

    Thanks for your help Allan. Unfortunately it is still not working. I was using node version 21.1.0 and npm version 10.2.0. I changed versions to match yours node v20.15.1 and npm 10.7.0 and I get the same error. I have tried to install in other applications and get the same error. I'm not sure how to check if I'm behind a proxy. I do get an error when trying to access the registry in the browser.

    I get this same error if I add /:_authToken=MYTOKENHERE to the end of that url.

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Its very odd! Are you able to connect through a different network, or try on a computer in a different location perhaps?

    I'm wondering if there is a proxy that is mashing the data being submitted in some way that the server isn't liking, but then I wouldn't expect it to give that error!

    Trying from a different location might help to narrow things down. I'll try combing through the error log tomorrow and see if there is anything obvious going on there.

    Allan

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin
    Answer ✓

    I've just tried the install on a different computer with a different network connection, and I got a 403 Forbidden for 2.4.1, but 2.4.0 installs cleanly. It looks like I got my dates slightly wrong for the package release date and the purchase - apologies. Perhaps you could try deleting your npm package lock file, the node_modules directory and then try:

    npm install '@datatables.net/editor-dt@2.4.0'
    

    Maybe that will make a difference.

    That said, I saw a 403, rather than 502. I had a look at the nginx error log and see a number of:

    2025/09/03 20:41:29 [error] 2513066#2513066: *93365172 upstream prematurely closed connection while reading response header from upstream
    

    There we no errors reported on or before 31st Aug, they started on 1st Sept, which I guess is perhaps when you first tried to install the package (UTC)?

    The npm server doesn't appear to be reporting any errors in its own logging.

    Allan

  • hjohnsickhjohnsick Posts: 12Questions: 5Answers: 0

    Thanks for your help Allan! I was able to get it working by using version @2.4.0. Is there a React component package for Datatables Editor? If so what would be the npm install for package?

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Excellent! We got there in the end. Weird that it was giving a 502 for you though. I'll keep an eye out for any similar reports.

    Regarding Editor and React, there is no need for an Editor React package / component. It doesn't have a component on in the HTML, the display is triggered by other Javascript actions (e.g. calling the edit() method), which will add the Editor elements to the DOM.

    Allan

Sign In or Register to comment.