Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running yarn add PACKAGE doesn't add the package to packages.json
If the current behavior is a bug, please provide the steps to reproduce.
yarn add koa-helmet (or any other package)success Saved lockfile.
success Saved 1 new dependency.
What is the expected behavior?
Expect package.json to be updated with
"koa-helmet": "^3.2.0",
Please mention your node.js, yarn and operating system version.
โฏ node -v
v8.0.0
โฏ yarn -V
0.24.6
โฏ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.5
BuildVersion: 16F73
The funny thing is that running npm i -S koa-helmet from the exact same folder worked as expected: it added a new line to package.json.
Noticed today, spent some time trying to understand why didn't my Node couldn't find a package even though I have installed it hehe.
My theory is that it might be linked with a node upgrade, which I did yesterday.
Tried with reinstalling yarn using brew, got the same result.
Cannot reproduce :(
โฏ [mael-mbp?] /Users/mael/test โฏ rm -rf package.json node_modules && echo '{}' > package.json && yarn && yarn add koa-helmet && cat package.json
yarn install v0.23.4
info No lockfile found.
warning No license field
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐ Building fresh packages...
success Saved lockfile.
โจ Done in 0.05s.
yarn add v0.23.4
warning No license field
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐ Building fresh packages...
success Saved lockfile.
success Saved 33 new dependencies.
warning No license field
โจ Done in 1.30s.
{
"dependencies": {
"koa-helmet": "^3.2.0"
}
}
Just wanted to add that now this works as expected for me. I don't know what caused this (a theory is that Docker's volume prevented package.json from being updated, but I don't want to check it now)
Thanks for a follow-up, @cbrwizard
I think I figured out the problem here: node-gyp. If your package.json has a dep that requires node-gyp and node-gyp doesn't exist, yarn will say it worked -- but doesn't -- and package.json won't be updated.
In my case, this dep was canvas-prebuilt.
In the yarn output, yarn was complaining about node-gyp command not found when running with my hombrew-installed-nodejs. No idea why no node-gyp, but switching to nvm use 8 (8.0.0) resolved the problem.
Yarn finds node-gyp and all is once again right with the world.
I had the same issue as @cmawhorter. Updating node from v8.6.0 to v8.9.4 fixed it for me.
I just noticed the same issue with node 9.5.0.
When I use node version v9.8.0, I noticed yarn does not add any info in package.json.
So I change node version to v8.10.0 and it just works.
Just noticed this using Node v10.2.0 and node-sqlcipher, a library that also depends on node-gyp. Everything looked fine, but node_modules/
Seems like a bug with node-gyp. Once I added node-gyp as a dev dependency myself, in my own project, everything started working (i.e. yarn add --dev node-gyp).
Most helpful comment
I think I figured out the problem here: node-gyp. If your package.json has a dep that requires node-gyp and node-gyp doesn't exist, yarn will say it worked -- but doesn't -- and package.json won't be updated.
In my case, this dep was canvas-prebuilt.
In the yarn output, yarn was complaining about
node-gyp command not foundwhen running with my hombrew-installed-nodejs. No idea why no node-gyp, but switching to nvm use 8 (8.0.0) resolved the problem.Yarn finds node-gyp and all is once again right with the world.