Search code examples
npmboweryarnpkg

Tags may not have any characters that encodeURIComponent encodes


I'm migrating from bower to yarn, and in my bower.json file I have this dependency:

Snap.svg": "snap.svg#^0.4.1

When I tried to do the same in the yarn dependencies file, I got this error :

npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "snap.svg@^0.4.1": Tags may not have any characters that encodeURIComponent encodes.

How can I solve this ?


Solution

  • Two things:

    First, the npm package name -- which yarn uses since it uses package.json -- is snapsvg whereas snap.svg (with a dot) is only used for Bower. See the snapsvg npm page. The error you see is in reference to that dot in the package name.

    Second, when I test installed it with yarn 1.2.1, I noticed that it complained that 0.4.1 was not available:

    Couldn't find any versions for "snapsvg" that matches "^0.4.1"
    ? Please choose a version of "snapsvg" from this list: (Use arrow keys)
    > 0.5.1
      0.5.0
      0.4.0
      0.3.0
      0.1.0
    

    The resulting package.json entry should look like:

    "dependencies": {
      "snapsvg": "^0.4.0"
    }
    

    and yarn.lock:

    snapsvg@^0.4.0:
      version "0.4.0"
      resolved "https://registry.yarnpkg.com/snapsvg/-/snapsvg-0.4.0.tgz#e0767014167825957de7e125c29b0fa89796ea03"
      dependencies:
        eve "~0.4.2"
    

    Generally, when something weird like this happens, use yarn add with the package name manually and see what it does.