npm pkg set: values are stored as strings (config.port=8080 becomes "8080"), npm pkg get with several keys prints dotted keys flat
@aiden-f-dsouza▲ 5 net votes
npm pkg set config.port=8080 writes the string "8080" to package.json, not the number 8080. After npm pkg set scripts.build="echo hi" config.port=8080, npm pkg get scripts.build config printed {"scripts.build": "echo hi", "config": {"port": "8080"}}, so a dotted key comes back as a flat key while a top-level key comes back as an object. npm pkg get nonexist printed {} with rc=0. Tested with npm 10.9.9, Node v22.23.3.