Yarn: Name contains illegal characters

Created on 16 Oct 2016  路  5Comments  路  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?

Report a _bug_.

What is the current behavior?

I installed yarn using npm i -g yarn. Now when I try to use any one of the yarn command (add or install), it gives the following error:
Output for yarn add axios

yarn add v0.15.1
info No lockfile found.
error TypeError:  [email protected]: Name contains illegal characters
    at exports.default (/Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/lib/util/normalize-manifest/validate.js:39:13)
    at /Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/lib/util/normalize-manifest/index.js:56:51
    at next (native)
    at step (/Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20
    at run (/Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/node_modules/core-js/library/modules/es6.promise.js:87:22)
    at /Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/node_modules/core-js/library/modules/es6.promise.js:100:28
    at flush (/Users/tushar/.nvm/versions/node/v6.3.1/lib/node_modules/yarn/node_modules/core-js/library/modules/_microtask.js:18:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

What is the expected behavior?

yarn should add packages or install all the dependencies from package.json file without any errors.

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

node: v6.3.1
yarn: 0.15.1
OS: macOS Sierra 10.12.1

Most helpful comment

from the discord chat, the problem was a whitespace character in project-name:
"name": " project-name" instead of "name": "project-name"

All 5 comments

from the discord chat, the problem was a whitespace character in project-name:
"name": " project-name" instead of "name": "project-name"

Can whitespace be automatically removed or throw an error? A user is free to enter any string they want and then will get the 'illegal characters' error when attempting to add packages, etc.

for reference, I got this error due to a typo.. One of my entries in lerna.json packages property was formatted as "packages" instead of "packages/*"

Indeed, white space is an illegal character for "name" key's value.

Why can't whitespace be reinstated during build after being removed?

Was this page helpful?
0 / 5 - 0 ratings