question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug?]: 405 (Method Not Allowed) on install of private registry dependencies

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

After migrating from Yarn v1 -> v3 and running yarn install I get…

The remote server failed to provide the requested resource
➤ YN0035: │   Response Code: 405 (Method Not Allowed)
➤ YN0035: │   Request Method: GET
➤ YN0035: │   Request URL: https://npm.pkg.github.com/@ourscope/eslint-config-react/-/eslint-config-react-2.1.0.tgz

this happens for both @ourscope/react-components and @ourscope/eslint-config-react

One thing that seems odd is the Request URL having a /-/ in it. and visiting that url in a browser nets with this…

{
"status": "error",
"message": "Method not allowed"
}

~/.yarnrc.yml (user home dir)

npmScopes:
  ourscope:
    npmAlwaysAuth: true
    npmAuthToken: "NOTTELLING"
    npmPublishRegistry: "https://npm.pkg.github.com"
    npmRegistryServer: "https://npm.pkg.github.com"

.yarnrc.yml (repo root)

yarnPath: .yarn/releases/yarn-3.1.0.cjs
nodeLinker: node_modules

Removing the npmAuthToken indeed errors with a not authorized error… so it seems the token is working properly.

package.json (workspace’s package.json)

{
  "name": "frontend",
  "description": "Great stuff",
  "version": "1.0.0",
  "author": "Us",
  "bugs": {
    "url": "https://github.com/NOTTELLING"
  },
  "dependencies": {
    "@ourscope/react-components": "5.52.0",
    "@material-ui/core": "^4.12.3",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.58",
    "@material-ui/styles": "^4.11.3",
    "@material-ui/system": "^4.11.3",
    "@reach/router": "^1.3.4",
    "@react-three/drei": "^3.9.0",
    "autosuggest-highlight": "^3.1.1",
    "axios": "^0.21.1",
    "formik": "^2.2.0",
    "gatsby": "^3.6.2",
    "gatsby-cli": "^3.6.0",
    "gatsby-plugin-feed": "^3.1.0",
    "gatsby-plugin-google-gtag": "^3.1.0",
    "gatsby-plugin-hubspot": "^1.3.5",
    "gatsby-plugin-image": "^1.2.1",
    "gatsby-plugin-manifest": "^3.1.0",
    "gatsby-plugin-material-ui": "^3.0.1",
    "gatsby-plugin-react-helmet": "^4.1.0",
    "gatsby-plugin-sharp": "^3.2.1",
    "gatsby-plugin-styled-components": "^4.1.0",
    "gatsby-source-filesystem": "^3.1.0",
    "gatsby-transformer-sharp": "^3.1.0",
    "gsap": "3.6.0",
    "lodash": "^4.17.21",
    "prop-types": "^15.7.2",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",
    "react-intersection-observer": "^8.31.0",
    "react-is": "^17.0.1",
    "react-portal": "^4.2.1",
    "react-responsive": "^8.2.0",
    "react-slick": "^0.28.1",
    "react-three-fiber": "^5.3.19",
    "react-use": "^17.2.3",
    "styled-components": "5.2.0",
    "styled-icons": "^10.33.0",
    "three": "^0.127.0",
    "uuid": "^8.3.1",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/core": "^7.13.15",
    "@babel/preset-env": "^7.13.15",
    "@babel/preset-react": "^7.12.13",
    "@babel/register": "^7.13.8",
    "@ourscope/eslint-config-react": "^2.1.0",
    "@typescript-eslint/eslint-plugin": "^4.21.0",
    "@typescript-eslint/parser": "^4.21.0",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.0.6",
    "babel-plugin-styled-components": "1.10.5",
    "babel-preset-gatsby": "^1.6.0",
    "dotenv": "^8.2.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-config-react-app": "^6.0.0",
    "eslint-plugin-flowtype": "^5.6.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-mdx": "^1.13.0",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.1.2",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "esm": "^3.2.25",
    "gatsby-plugin-no-javascript": "^2.0.5",
    "gatsby-plugin-remove-trailing-slashes": "^3.1.0",
    "gatsby-plugin-robots-txt": "^1.5.5",
    "gatsby-plugin-sitemap": "^4.1.0",
    "gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.22",
    "http-proxy-middleware": "^1.0.6",
    "lint-staged": "^10.5.4",
    "prettier": "^2.1.2",
    "typescript": "^4.2.4",
    "webpack-node-externals": "^3.0.0"
  },
  "resolutions": {
    "**/babel-plugin-styled-components": "1.10.5",
    "**/browserslist": "^4.16.6",
    "**/ws": "^7.4.6",
    "**/trim": "^0.0.3",
    "**/property-expr": "^2.0.3",
    "**/postcss": "^8.2.10",
    "**/lodash": "^4.17.21"
  },
  "homepage": "https://github.com/ourscope/nottelling#readme",
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ourscope/nottelling.git"
  },
  "scripts": {
    "lint": "eslint --ext \".js,.ts,.tsx,.mdx\" .",
    "build": "gatsby build",
    "develop": "gatsby develop -H 0.0.0.0",
    "format": "eslint --fix --ignore-pattern public \"**/*.{js,jsx}\"",
    "start": "npm run develop",
    "serve": "gatsby serve -H 0.0.0.0",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing \""
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "pre-push": "yarn lint",
      "post-rebase": "yarn install"
    }
  },
  "lint-staged": {
    "*.{js,ts,tsx}": [
      "eslint --fix"
    ]
  }
}

To reproduce

It’s a private repo and token so not sure how to provide repro steps?

Environment

System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.15.1 - /private/var/folders/wg/0wjnjmw153n_smp01x_tp3zw0000gp/T/xfs-fdc5c3bc/node
    Yarn: 3.1.0 - /private/var/folders/wg/0wjnjmw153n_smp01x_tp3zw0000gp/T/xfs-fdc5c3bc/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.1/bin/npm

Additional context

The above was all done in a repo that already worked in v1 with workspaces. We just tried an empty folder… yarn init yarn set version berry yarn init (needed to run twice for some reason) yarn add @ourscope/react-components

and everything worked as expected… no issues and this would be with the same ~/.yarnrc.yml as above.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ofagbemicommented, Dec 30, 2021

In case anyone’s coming from search — I had a similar error and was able to fix it by just deleting my private package’s entry in my yarn.lock file before running yarn install

2reactions
iDVBcommented, Nov 11, 2021

Turns out our issue what that we we’re not using the proper nodeLinker. We had it as node_modules and it was supposed to be node-modules.

Btw, who’s decision was it to use a hyphen here?! 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm install fails with 405 Method Not Allowed - Stack Overflow
We're using github as npm repository for our private packages. Now I am getting this error on npm install: npm ERR! code E405...
Read more >
How to Fix HTTP Error 405 Method Not Allowed - Hostinger
When a website shows the 405 Method Not Allowed notification, it indicates a Hypertext Transfer Protocol (HTTP) error.
Read more >
How to Fix the HTTP 405 Method Not Allowed Error - Kinsta®
1. Check to See If You've Input the Correct URL. It may sound a little too simple but the most common cause of...
Read more >
Getting 404 Registry returned when trying to run npm install #15
This problem occurs for companies that must use private npm proxies, mostly old ones do not properly support npm organisations.
Read more >
405 Method Not Allowed: What It Is and How to Fix It
This code response confirms that the requested resource is valid and exists, but the client has used an unacceptable HTTP method during the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found