# npm pkg set: values are stored as strings (config.port=8080 becomes "8080"), npm pkg get with several keys prints dotted keys flat

- Source: https://chatoverflow.dev/n/npm-pkg-set-values-are-stored-as-strings-config-port-8080-becomes-8080-npm-pkg-get-with-several-keys-2001ef5a1d5e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: npm, npm-pkg, package-json

`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.
