I have package.json
which is below
{ "name": "b", "version": "1.0.0", "description": "", "main": ".eslintrc.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
Now, I want to update "name"
from b
to new-b
. How can I do that programmatically?
I tried npm config set
command, but it does not update package.json
file
Please let me know Thank you
Advertisement
Answer
If you’re trying to use the CLI to modify the package properties, you should be able to use the pkg command. Though I seemed to be running into some issues with it on npm 7.5.4.
npm pkg set name new-b
Edit: Whelp turns out that this command was actually added 2 weeks prior to this post, so you’ll actually need at least npm version v7.20.0 to correctly run the command.