Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn cannot handle "//" package #2484

Closed
nkovacs opened this issue Jan 18, 2017 · 6 comments
Closed

Yarn cannot handle "//" package #2484

nkovacs opened this issue Jan 18, 2017 · 6 comments

Comments

@nkovacs
Copy link

nkovacs commented Jan 18, 2017

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

bug

What is the current behavior?

According to Isaac Schlueter, this is a valid way to add comments to your package.json: https://groups.google.com/forum/#!msg/nodejs/NmL7jdeuw0M/yTqI05DRQrIJ

Yarn 0.19.1 does not support this. You can add a package that has a package.json like this, but if you try to run yarn install after that, it will fail.

yarn-error.log:

Yarn version: 
  0.19.1

Node version: 
  6.9.4

Platform: 
  linux x64

npm manifest: 
  {
    "name": "yarntest",
    "version": "1.0.0",
    "main": "index.js",
    "repository": {},
    "license": "MIT",
    "dependencies": {
      "keyczarjs": "^0.1.0"
    }
  }

yarn manifest: 
  No manifest

Lockfile: 
  # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
  # yarn lockfile v1
  
  
  keyczarjs@^0.1.0:
    version "0.1.0"
    resolved "https://registry.yarnpkg.com/keyczarjs/-/keyczarjs-0.1.0.tgz#c2f57f256a13211e967b842e034d201b4d45e837"
    dependencies:
      "//":
        "0" "Pinned version to avoid breaking us when something changes"
        "1" "we have twice had something break, so this way we control it."
        "2" "To test with the latest development version, use this:"
        "3" "git://github.com/digitalbazaar/forge.git"
      node-forge "0.3.0"
  
  node-forge@0.3.0:
    version "0.3.0"
    resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.3.0.tgz#c428ed8d858c549ea146eac8123703c636b21965"

Trace: 
  TypeError: Cannot convert object to primitive value
      at /usr/share/yarn/lib/package-request.js:322:42
      at next (native)
      at step (/usr/share/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at /usr/share/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

I also tested with a non-array comment package in my package.json, in that case the error was: "Received malformed response from registry for undefined. The registry may be down."

If the current behavior is a bug, please provide the steps to reproduce.

  1. yarn init
  2. yarn add keyczarjs
  3. yarn install

What is the expected behavior?

yarn install works. yarn ignores the "//" package.

Please mention your node.js, yarn and operating system version.

Ubuntu 16.10
Yarn version: 0.19.1
Node version: 6.9.4

@dawsbot
Copy link
Contributor

dawsbot commented Apr 27, 2017

Landed the fix to the popular package keyczarjs which informed me of this problem.

@Daniel15 Feel free to upvote my PR over on keyczarjs

@rally25rs
Copy link
Contributor

The keyczarjs package has since removed that comment, but Yarn v0.24.6 still does not support "//" comments in package.json.

NPM seems to handle it fine.

Yarn should remove "comment" items from the loaded package.json. There are several existing libraries that can be used to do this.

@jseminck
Copy link
Contributor

jseminck commented Jul 4, 2017

I'm taking a look at this. Hopefully can make a PR later today or tomorrow.

@bartaz
Copy link

bartaz commented Sep 4, 2017

Is this fixed?
The PR #3829 seems to be merged, but I get an error when trying to run yarn install on package.json with comments in dependencies.

Example package.json:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "//": "test"
  }
}

Error:

> yarn install
yarn install v0.27.5
[1/4] Resolving packages...
error Received malformed response from registry for undefined. The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@BYK
Copy link
Member

BYK commented Sep 4, 2017

@bartaz the fix is on latest nightlies and will be released with 1.0 very soon.

@bartaz
Copy link

bartaz commented Sep 4, 2017

@BYK thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants