'Yarn install command dont run correctly

My env

Yarn version: 3.1.1
Node version: v16.12.0
Ubuntu: 20.04

I created a new project at ~/projects/test-yarn then run command in test-yarn folder and got error

yarn init

yarn add vue

Usage Error: The project in /home/MY_NAME/package.json doesn't seem to have been installed - running an install there might help

$ yarn add [--json] [-E,--exact] [-T,--tilde] [-C,--caret] [-D,--dev] [-P,--peer] [-O,--optional] [--prefer-dev] [-i,--interactive] [--cached] [--mode #0] ...

This is package.json

{
  "name": "test-yarn",
  "packageManager": "[email protected]"
}

It looks like yarn always run at /home/MY_NAME/ folder.

Pleas help to resolve this.



Solution 1:[1]

I found the root cause:

At /home/MY_NAME/ has a yarn.lock' and package.json` file. Removing them, and it work well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 anhduc.bkhn