surmon-china / vue-codemirror

@codemirror code editor component for @vuejs
https://github.surmon.me/vue-codemirror
MIT License
3.29k stars 383 forks source link

vite 2.9 use yarn instll build report errors Rollup failed to resolve import "codemirror" from "node_modules/vue-codemirror/dist/vue-codemirror.esm.js". #153

Closed yixinagqingyuan closed 2 years ago

yixinagqingyuan commented 2 years ago

Describe the bug

vite 2.9 use yarn instll build report errors
[vite]: Rollup failed to resolve import "codemirror" from "node_modules/vue-codemirror/dist/vue-codemirror.esm.js". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.external error during build: Error: [vite]: Rollup failed to resolve import "codemirror" from "node_modules/vue-codemirror/dist/vue-codemirror.esm.js". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.external at onRollupWarning (/Users/a58/58_project/idot-editor-vue/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:41772:19) at onwarn (/Users/a58/58_project/idot-editor-vue/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:41588:13) at Object.onwarn (/Users/a58/58_project/idot-editor-vue/node_modules/rollup/dist/shared/rollup.js:23226:13) at ModuleLoader.handleResolveId (/Users/a58/58_project/idot-editor-vue/node_modules/rollup/dist/shared/rollup.js:22510:26) at /Users/a58/58_project/idot-editor-vue/node_modules/rollup/dist/shared/rollup.js:22471:26

use npm install normal

Reproduction

"vue-codemirror": "^6.0.0", report errors

System Info

System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1
    Memory: 93.98 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Firefox: 95.0.2
    Safari: 15.5
  npmPackages:
    @codemirror/lang-css: ^6.0.0 => 6.0.0 
    @codemirror/lang-html: ^6.1.0 => 6.1.0 
    @codemirror/lang-javascript: ^6.0.1 => 6.0.1 
    @codemirror/lang-json: ^6.0.0 => 6.0.0 
    @codemirror/lang-markdown: ^6.0.0 => 6.0.0 
    @codemirror/state: 6.x => 6.1.0 
    @codemirror/theme-one-dark: ^6.0.0 => 6.0.0 
    @element-plus/icons-vue: ^2.0.5 => 2.0.6 
    @types/jest: ^28.1.3 => 28.1.4 
    @types/node: ^17.0.35 => 17.0.45 
    @vitejs/plugin-vue: ^2.3.3 => 2.3.3 
    algoliasearch: ^4.13.1 => 4.13.1 
    axios: ^0.27.2 => 0.27.2 
    crypto-js: ^4.1.1 => 4.1.1 
    custom-sandpack-client: ^0.1.26 => 0.1.26 
    element-plus: ^2.2.6 => 2.2.9 
    lodash: ^4.17.21 => 4.17.21 
    monaco-editor: ^0.33.0 => 0.33.0 
    normalize.css: ^8.0.1 => 8.0.1 
    pinia: ^2.0.14 => 2.0.14 
    rollup-plugin-visualizer: ^5.6.0 => 5.6.0 
    sass: ^1.51.0 => 1.53.0 
    splitpanes: ^3.1.1 => 3.1.1 
    typescript: ^4.7.4 => 4.7.4 
    unplugin-auto-import: ^0.7.2 => 0.7.2 
    unplugin-vue-components: ^0.19.5 => 0.19.9 
    vite: ^2.9.9 => 2.9.13 
    vue: ^3.2.25 => 3.2.37 
    vue-codemirror: ^6.0.0 => 6.0.0 
    vue-router: ^4.0.15 => 4.1.1 
    vue-tsc: ^0.34.7 => 0.34.17 
    vuedraggable: ^4.1.0 => 4.1.0 
    vuex: ^4.0.2 => 4.0.2

Used Package Manager

yarn

Validations

surmon-china commented 2 years ago

Note that starting from v6.0, you need to install codemirror as well.

yarn add codemirror vue-codemirror

yarn add vue-codemirror
yixinagqingyuan commented 2 years ago

All are installed, but the installation will fail if you use yarn. NPM is OK

yixinagqingyuan commented 2 years ago

ok, In addition to using "@codemirror/state": "6.x", you also need to "install codemirror": "^6.0.1" when using yarn to install, NPM does not need to install codemirror ":" ^6.0.1“