Skip to content

npm run link-watch produces "type in ./package.json must be of type 'commonjs' | 'module' (received undefined)" #59

@wildseansy

Description

@wildseansy

When running the README.md quick run steps, the package.json doesn't seem to be properly configured.

# Initialize a new plugin (outside of your Sanity studio folder)
npx @sanity/plugin-kit init sanity-plugin-testing-it-out

# Make your plugin linkable, and compile an initial version
cd sanity-plugin-testing-it-out
npm run link-watch

npm run link-watch produces

[error] `type` in `./package.json` must be of type 'commonjs' | 'module' (received undefined)

To fix this

  1. The plugin template package.json needs "type": "module" added
  2. "exports": {
     ".": {
       "types": "./lib/src/index.d.ts",
       "source": "./src/index.ts",
       "import": "./lib/index.esm.js",
       "require": "./lib/index.js", // Update to .cjs
       "default": "./lib/index.esm.js"
     },
     "main": "./lib/index.js", //update to .cjs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions