Do you want to request a _feature_ or report a _bug_?
Bug
What is the current behavior?
When Yarn is installed locally and not in listed in the package.json, yarn add will delete the locally installed yarn and hang when installing another package.
If the current behavior is a bug, please provide the steps to reproduce.
mkdir test
cd test
npm i yarn
./node_modules/.bin/yarn add leftpad
Yarn hangs after logging
yarn add v0.16.1
[1/4] 馃攳 Resolving packages...
[2/4] 馃殮 Fetching packages...
[3/4] 馃敆 Linking dependencies...
[4/4] 馃搩 Building fresh packages...
Pressing CTRLC logs the error
^CError: Cannot find module '../errors.js'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at _load_errors (/Users/rberdeen/test/node_modules/yarn/lib/cli/index.js:42:20)
at config.init.then.catch.err (/Users/rberdeen/test/node_modules/yarn/lib/cli/index.js:388:34)
at process._tickCallback (internal/process/next_tick.js:103:7)
The yarn package is gone, which explains the exception.
$ ls node_modules
leftpad
What is the expected behavior?
Yarn should log an error and exit, rather that hanging.
It makes sense that the yarn package is deleted, as it isn't listed in the package.json
Please mention your node.js, yarn and operating system version.
npm v6.5.0
node v6.5.0
yarn v0.16.1
OS X 10.11.6 and CentOS 6.7
This is intentional. Yarn needs to be installed globally. We wipe node_modules for packages not specified in package.json. You could fix this by doing npm install --save yarn.
@kittens The issue here is that Yarn hangs and never logs an error, which makes it difficult to track down the actual issue. Like I noted in the description, it makes sense that yarn deletes itself.
I was hoping for a message indicating that the Yarn installation wouldn't work.
Yarn needs to be installed globally.
Is this going to be a requirement? I was planning to use the Yarn JS API which was mentioned in the introductory blog post. In this case I'd definitely want a specific Yarn version specified in my package.json and installed locally.
Most helpful comment
@kittens The issue here is that Yarn hangs and never logs an error, which makes it difficult to track down the actual issue. Like I noted in the description, it makes sense that yarn deletes itself.
I was hoping for a message indicating that the Yarn installation wouldn't work.
Is this going to be a requirement? I was planning to use the Yarn JS API which was mentioned in the introductory blog post. In this case I'd definitely want a specific Yarn version specified in my
package.jsonand installed locally.