josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
818 stars 108 forks source link

No "exports" main defined #320

Closed Lukkyz closed 8 months ago

Lukkyz commented 8 months ago

I want to use vue-json-editor and this json editor is a dependency.. When importing vue-json-editor I have the error : No "exports" main defined in /home/user/project/node_modules/vanilla-jsoneditor/package.json imported from /home/user/project/node_modules/json-editor-vue/dist/json-editor-vue.mjs Here is the package.json from vanilla-jsoneditor :

{
  "name": "vanilla-jsoneditor",
  "description": "A web-based tool to view, edit, format, transform, and validate JSON",
  "version": "0.18.9",
  "homepage": "https://github.com/josdejong/svelte-jsoneditor",
  "repository": {
    "type": "git",
    "url": "https://github.com/josdejong/svelte-jsoneditor.git"
  },
  "type": "module",
  "module": "./index.js",
  "main": "./index.js",
  "types": "./index.d.ts",
  "sideEffects": false,
  "license": "ISC",
  "exports": {
    ".": {
      "types": "./index.d.ts",
      "module": "./index.js"
    },
    "./CHANGELOG.md": "./CHANGELOG.md",
    "./index.d.ts": "./index.d.ts",
    "./index.js": "./index.js",
    "./index.js.map": "./index.js.map",
    "./LICENSE.md": "./LICENSE.md",
    "./README.md": "./README.md",
    "./SECURITY.md": "./SECURITY.md",
    "./themes/jse-theme-dark.css": "./themes/jse-theme-dark.css",
    "./themes/jse-theme-default.css": "./themes/jse-theme-default.css",
    "./package.json": "./package.json"
  },
  "files": [
    "*"
  ],
  "scripts": {},
  "dependencies": {
    "@fortawesome/free-solid-svg-icons": "^6.4.2",
    "ajv": "^8.12.0",
    "immutable-json-patch": "^5.1.3",
    "svelte": "^4.2.1"
  },
  "devDependencies": {}
}

My project run on nuxt 3.7.3

josdejong commented 8 months ago

Thanks for reporting. How can I reproduce this issue exactly?

And what version of Node.js are you using? This error may occur when using old node.js versions it seems, no clue if you're hitting the same issue though.

Lukkyz commented 8 months ago

I use node 18.18.1 For reproducing : Create a nuxt project : npx nuxi@latest init <project-name> npm i json-editor-vue vanilla-jsoneditor In app.vue or in a page :

<script setup>
import JsonEditorVue from 'json-editor-vue'
let value = ref()
</script>

<template>
    <JsonEditorVue
       v-model="value"
     />
</template>
josdejong commented 8 months ago

I followed your steps, and it just gives a working editor, no errors. Only difference is that I'm running node.js 20.5.0 and Nuxt 3.7.4 with Nitro 2.6.3.

husayt commented 8 months ago

I am getting this error with latest json-editor-vue and vitepress during build.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in x\node_modules\vanilla-jsoneditor\package.json imported from x\node_modules\json-editor-vue\dist\json-editor-vue.mjs

josdejong commented 8 months ago

Thanks for your input @husayt .

How can I reproduce the issue? Any chance of creating a git repo with a minimal demo of the issue?

husayt commented 8 months ago

@josdejong this has been fixed with latest version of json-editor-vue. FYI, it seems, switching to peerdependency, did the trick.

You can see the change here.

Thank you

josdejong commented 8 months ago

👍 that's good to hear. I'll close this issue, assuming the issue of @Lukkyz was the very same. Please reopen if needed.