yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

Scoped Packages - "yarn add" (not "yarn") throws error #5263

Open mblandfo opened 6 years ago

mblandfo commented 6 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior?

Yarn add command cannot install this published package: https://www.npmjs.com/package/@google-cloud/translate

$ yarn add @google-cloud/translate
yarn add v1.3.2
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@google-cloud/
translate: Not found".

npm can install it correctly:

$npm install @google-cloud/translate --save

"yarn" does install it correctly if it is in the package.json, it is just "yarn add" that fails.

Interestingly, bluebird gives a slightly different error:

$ yarn add @types/bluebird
yarn add v1.3.2
[1/4] Resolving packages...
error Couldn't find package "@types\\bluebird" on the "npm" registry.

Both work from package.json, and wrapping them in quotes in yarn add doesn't matter.

Please mention your node.js, yarn and operating system version. yarn 1.3.2 node v8.9.4 Windows 7

Related: #4354 #4366

rally25rs commented 6 years ago

Seems to work OK for me.

~/Projects/yarn-test 🐒   yarn add @google-cloud/translate
yarn add v1.4.0
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 94 new dependencies.
✨  Done in 2.99s.

~/Projects/yarn-test 🐒   yarn add @types/bluebird
yarn add v1.4.0
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ @types/bluebird@3.5.20
warning No license field
✨  Done in 0.73s.

~/Projects/yarn-test 🐒   cat package.json
{
  "dependencies": {
    "@google-cloud/translate": "^1.1.0",
    "@types/bluebird": "^3.5.20"
  }
}
~/Projects/yarn-test 🐒   rm -rf node_modules/

~/Projects/yarn-test 🐒   yarn
yarn install v1.4.0
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
✨  Done in 0.72s.

Maybe try upgrading to yarn v1.4 and see if it's already fixed?

mblandfo commented 6 years ago

No, I still see the issue on windows 7.

$ yarn add @google-cloud/translate
yarn add v1.4.1-20180129.1936
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@google-cloud/
translate: Not found".
daelmaak commented 6 years ago

Still an issue on win10 with yarn 1.6.0 Seems like it has something to do with scoped packages. I don't have problem installing those without '@'

$ yarn add @ngx-translate/core
yarn add v1.6.0
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@ngx-translate/core: 
Not found".
rally25rs commented 6 years ago

I still can't reproduce this. Tried on Win 10, yarn 1.5.1, powershell and it still worked for me. If someone why can consistently reproduce this can help debug, we would appreciate it.

What should happen is that yarn uses the url https://registry.yarnpkg.com/@google-cloud%2ftranslate but instead it is putting a / instead of the %2f.

daelmaak commented 6 years ago

I was playing around and found out it doesn't happen in windows terminal, but it fails when attempting yarn add @ngx-translate/core in git bash.

prayerslayer commented 6 years ago

Can confirm this issue. Package: https://www.npmjs.com/package/@types/react I realize now it's because of a typo: types/react (correct) vs typed/react (what i tried). Sorry for wasting everyone's time.

$> yarn add --dev @typed/react                                                                                     
yarn add v1.5.1
[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@typed%2freact: Not found".
info If you think this is a bug, please open a bug report with the information provided in "[stripped]".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

macOS 10.13.2 iTerm2 3.1.6 fish 2.7.1 / bash 3.2 yarn 1.5.1 node 8.9.3

Problem persists after upgrading to node 9.11.1 and yarn 1.6.0. Same if I add the package to my package.json:

$> yarn                                                                                                             14:33:58
yarn install v1.6.0
[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@typed%2freact: Not found".
dvelasquez25 commented 4 years ago

Can confirm this issue Ubuntu 20.04 Yarn 1.22.5 Node 12.18.0 Zsh 5.8