[Bug] Can't add packages: This command can only be run from within a workspace of your project
See original GitHub issueI created a folder called hello-world
then ran yarn init
.
It created a file called package.json
with this content:
{
"name": "hello-world"
}
Then I try to install a package, for example moment
: yarn add moment
.
I get this error:
Usage Error: This command can only be run from within a workspace of your project (Desktop/hello-world isn't a workspace of /C:/Users/Joel/package.json).
and /C:/Users/Joel/package.json
doesn’t exist, because I deleted it to see if it would fix the problem, but it didn’t.
Is there a way to use yarn without dealing with all that workspace thing, I thought I could just replace npm with yarn…
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:5 (1 by maintainers)
Top Results From Across the Web
npm ci can only install packages with an ... - Stack Overflow
The npm ERR! The 'npm ci' command can only install with an existing package-lock.json wasn't a super helpful error in that case.
Read more >Workspaces - Yarn
Workspaces are a new way to set up your package architecture that's available by default starting from Yarn 1.0. It allows you to...
Read more >Adding package dependencies to your app - Apple Developer
Add a package dependency. To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and...
Read more >Using Python environments in VS Code
An "environment" in Python is the context in which a Python program runs and consists of ... any packages you install are installed...
Read more >Project Configuration - Nx
If you want to ignore a particular package.json file, exclude it from those tools. For example, you can add !packages/myproject to the workspaces...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can reproduce this on my machine (macOS). Creating an empty
yarn.lock
file in your package directory (i.e. atC:\Users\Joel\Desktop\hello-world\yarn.lock
) makes it work.I’d like to be able to have multiple packages in my repo without being forced to use workspaces.
This is the best I could do for a repro. Since the yarn command fails, it says the reproduction is invalid. I think you all need to reconsider this requirement for a reproduction using Sherlock when an issue is opened with clear and concise repro instructions.