vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.32k forks source link

run esmodule vue.config.js Error [ERR_UNSUPPORTED_ESM_URL_SCHEME] #6592

Open alamhubb opened 3 years ago

alamhubb commented 3 years ago

i use esmodule in vue.config.js

Version

5.0.0-beta.2

code

//package.json

  "type": "module"
//vue.config.js

import postcssAutoAdaptive from './postcss-auto-adaptive'

module.exports = {
  devServer: {
    disableHostCheck: true,
    host: '0.0.0.0',
    port: 9521,
    proxy: {
      // change xxx-api/login => mock/login
      // detail: https://cli.vuejs.org/config/#devserver-proxy
      [process.env.VUE_APP_BASE_API]: {
        // target: `http://172.16.6.83:8080/`,
        target: `http://172.16.160.68:8080/`,
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: '/'
        }
      }
    }
  },
  css: {
    loaderOptions: {
      postcss: {
        postcssOptions: {
          plugins: [
            postcssAutoAdaptive()
          ]
        }
      }
    }
  },
  publicPath: '/',
  outputDir: 'dist',
  lintOnSave: false,
  runtimeCompiler: true
}

Reproduction link

https://none

Environment info

Environment Info:

  System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
  Binaries:
    Node: 14.16.0 - D:\devlang\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.14.11 - D:\devlang\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.19041.423.0), Chromium (91.0.864.70)
  npmPackages:
    @antv/x6-vue-shape: ^1.1.6 => 1.2.4
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1
    @vue/babel-helper-vue-transform-on:  1.0.2
    @vue/babel-plugin-jsx:  1.0.6
    @vue/babel-plugin-transform-vue-jsx:  1.2.1
    @vue/babel-preset-app:  5.0.0-beta.2
    @vue/babel-preset-jsx:  1.2.4
    @vue/babel-sugar-composition-api-inject-h:  1.2.1
    @vue/babel-sugar-composition-api-render-instance:  1.2.4
    @vue/babel-sugar-functional-vue:  1.2.2
    @vue/babel-sugar-inject-h:  1.2.2
    @vue/babel-sugar-v-model:  1.2.3
    @vue/babel-sugar-v-on:  1.2.3
    @vue/cli-overlay:  5.0.0-beta.2
    @vue/cli-plugin-babel: ~5.0.0-beta.2 => 5.0.0-beta.2
    @vue/cli-plugin-eslint: ~5.0.0-beta.2 => 5.0.0-beta.2
    @vue/cli-plugin-router: ~5.0.0-beta.2 => 5.0.0-beta.2
    @vue/cli-plugin-typescript: ~5.0.0-beta.2 => 5.0.0-beta.2
    @vue/cli-plugin-vuex: ~5.0.0-beta.2 => 5.0.0-beta.2
    @vue/cli-service: ~5.0.0-beta.2 => 5.0.0-beta.2
    @vue/cli-shared-utils:  5.0.0-beta.2
    @vue/component-compiler-utils:  3.2.2
    @vue/composition-api: ^1.0.0-rc.10 => 1.0.0-rc.10
    @vue/eslint-config-typescript: ^7.0.0 => 7.0.0
    @vue/web-component-wrapper:  1.3.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    eslint-plugin-vue: ^6.2.2 => 6.2.2
    typescript: ^4.2.4 => 4.3.5
    vue: ^2.6.14 => 2.6.14
    vue-axios: ^2.1.5 => 2.1.5
    vue-class-component: ^7.2.3 => 7.2.6
    vue-clipboard2: ^0.3.1 => 0.3.1
    vue-demi:  0.7.5
    vue-eslint-parser:  7.6.0
    vue-hot-reload-api:  2.3.4
    vue-loader:  16.3.1 (15.9.7)
    vue-property-decorator: ^9.1.2 => 9.1.2
    vue-router: ^3.2.0 => 3.5.1
    vue-style-loader:  4.1.3
    vue-template-compiler: ^2.6.14 => 2.6.14
    vue-template-es2015-compiler:  1.9.1
    vuex: ^3.6.2 => 3.6.2
    vuex-class: ^0.3.2 => 0.3.2
    vuex-class-modules: ^1.3.0 => 1.3.0
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

none

What is expected?

none

What is actually happening?

ERROR Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// U RLs. Received protocol 'd:' Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Rec eived protocol 'd:' at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:782:11) at Loader.resolve (internal/modules/esm/loader.js:86:40) at Loader.getModuleJob (internal/modules/esm/loader.js:230:28) at Loader.import (internal/modules/esm/loader.js:165:28) at importModuleDynamically (internal/modules/cjs/loader.js:1006:27) at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14) at loadFileConfig (D:\project\yoyosys\console\console-2.0-installer\console-install-ui\node_modules\@vue\cli-service\lib\util\loadFileConfig.js:28:7) at Service.loadUserOptions (D:\project\yoyosys\console\console-2.0-installer\console-install-ui\node_modules\@vue\cli-service\lib\Service.js:337:44) at Service.init (D:\project\yoyosys\console\console-2.0-installer\console-install-ui\node_modules\@vue\cli-service\lib\Service.js:76:30) at Service.run (D:\project\yoyosys\console\console-2.0-installer\console-install-ui\node_modules\@vue\cli-service\lib\Service.js:245:16) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! console-install@0.1.0 serve: vue-cli-service serve npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the console-install@0.1.0 serve script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache_logs\2021-07-19T10_27_48_845Z-debug.log

Process finished with exit code 1


none

DRoet commented 3 years ago

You are still using CommonJS exports module.exports = {}. you should probably switch over to export default {}

vincerubinetti commented 2 years ago

This is still happening in 5.0.0-rc.1 (at least on windows).

This problem is also being talked about on Stack Overflow and someone points out the bug in vue-cli: https://stackoverflow.com/questions/69665780/error-err-unsupported-esm-url-scheme-only-file-and-data-urls-are-supported-by

parzhitsky commented 2 years ago

See a breakdown of why this actually happens

cowwoc commented 1 year ago

Hello from 2023. Can a committer please fix this issue?