Home > database >  How to add a dot in the package.json file using npm-pkg command?
How to add a dot in the package.json file using npm-pkg command?

Time:12-08

I want to use the npm pkg set command to generate a package.json file like this:

{
  ...
  "exports": {
    ".": {
      "import": "./dist/my-lib.js",
      "require": "./dist/my-lib.umd.cjs"
    }
  }
  ...
}

But I'm not able to add the "." key

I tried running npm pkg set exports..import=./dist/my-lib.js and npm pkg set exports.\.import=./dist/my-lib.js

CodePudding user response:

You can set a property directly in json format:

npm pkg set export='{".":{"import": "./dist/my-lib.js","require": "./dist/my-lib.umd.cjs"}}' --json

Please note that this will overwrite existing "export" property.

  • Related