Every yarn command gives "error ../package.json: Name contains illegal characters"
Asked Answered
M

6

9

Kia ora! I'm trying to install ghost-blog locally, but am running into an issue during install. It stops at "installing dependencies", and yarn install --no-emoji -no-progress (the command generated by ghost-cli) pulls an error: "../../../../package.json: Name contains illegal characters".

I've since then noticed that almost every yarn command (except yarn --version) gives the same error, including yarn cache clear, which is making it really hard to troubleshoot.

I've gone and hunted for package.json files floating around the system that might be causing it, since I read somewhere that yarn looks for the closest one, and deleted most of them - the ones remaining are part of npm packages and seem to have valid file/path names (all lower case, no spaces). I've also copied Ghost's package.json into the parent directory (as ghost-cli requires an empty directory to install) hoping yarn will pick that up instead, but no luck.

I've uninstalled and reinstalled yarn (via home-brew) and ensured it's in my profile (zsh).

Here's the output from ghost-cli-debug, unfortunately not very useful:

Debug Information:
    OS: Mac OS X, v10.15
    Node Version: v10.16.1
    Ghost-CLI Version: 1.11.0
    Environment: development
    Command: 'ghost install local'
Message: Command failed: yarn install --no-emoji --no-progress
error ../../../../package.json: Name contains illegal characters

yarn install v1.16.0
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Exit code: 1

--------------- stdout ---------------
yarn install v1.16.0
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


--------------- stderr ---------------
error ../../../../package.json: Name contains illegal characters

Any help would be greatly appreciated! I've done a bunch of searching but can't seem to find any similar issues.

Moreira answered 6/8, 2019 at 8:48 Comment(0)
N
24

in my package.json i had this

"name": "Shopping app",

then i solved the problem by removing the space and now i have this and its working perfectly

"name": "ShoppingApp",
Nigh answered 26/8, 2021 at 5:8 Comment(1)
I had this same issue also, this worked for me. ThanksOutgroup
G
11

In my case my package name had a space, so when I removed it everything just werked again.

Gusella answered 24/1, 2021 at 0:13 Comment(0)
M
10

Solved it - there was a random package.json in my root folder I somehow missed with a non-compliant name field ("App Name"), deleting it resolved everything.

Moreira answered 7/8, 2019 at 9:59 Comment(0)
G
1

In my case "name": in package.json had to be the lowercase but otherwise equal version of the folder name where the project lives.

So if my folder was foo_version_01, my app name had to be that instead of New Foo.

Giro answered 14/9, 2021 at 21:27 Comment(0)
N
1

In my case name in package.json had two forward slashes and only one was allowed

"name": "@aquila-ui/base/ui-kit" -> "name": "@aquila-ui/base-ui-kit"

Nephogram answered 22/5, 2023 at 12:51 Comment(0)
B
0

In my case i have given App name with space removing space resolved my issue.

Brill answered 12/7, 2021 at 11:25 Comment(1)
This has already been mentioned in the other answers.Zymogenesis

© 2022 - 2024 — McMap. All rights reserved.