Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
I try to install a package from a subdirectory. Yarn creates a new package.json in that subdirectory instead of in the package root.
If the current behavior is a bug, please provide the steps to reproduce.
mkdir parent
cd parent
yarn init
yarn add request
mkdir child
cd child
yarn add --dev lodash
cd ..
rm -r node_modules/ child/node_modules/
find .
This results in 2 package.json files, on in parent and one in child, together with 2 yarn.lock files.
.
./child
./child/package.json
./child/yarn.lock
./package.json
./yarn.lock
What is the expected behavior?
Based on the documentation ("...within the root directory of your package...") I would expect yarn to find my package.json in the top directory and install the package there.
Please mention your node.js, yarn and operating system version.
nodejs: 4.4.3
yarn: 0.19.1
OS: OSX 10.11.6
Unfortunately, most of the commands don't work if executed in sub-directories. I don't know the desired behaviour here.
npm install, npm run, both find the correct root. yarn variants don't. It's enough to make me not use yarn.
The desired behaviour should be to search for package.json in parent directories up to the filesystem root and then install into its parent directory.
I run into this issue almost daily when I forget to cd to the project root before yarn add.
This is fixed by #4246 but it will not work for yarn init after #4441 is closed.
Most helpful comment
npm install, npm run, both find the correct root. yarn variants don't. It's enough to make me not use yarn.