Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read file when use "resolve.alias" with cdn url #2268

Closed
3 tasks done
FanhuaCloud opened this issue Feb 26, 2021 · 0 comments
Closed
3 tasks done

Cannot read file when use "resolve.alias" with cdn url #2268

FanhuaCloud opened this issue Feb 26, 2021 · 0 comments

Comments

@FanhuaCloud
Copy link

FanhuaCloud commented Feb 26, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

A clear and concise description of what the bug is.
vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve:{
    alias:{
      "vue":"https://cdn.jsdelivr.net/npm/vue@3.0.6/dist/vue.esm-browser.js"
    }
  }
})

main.js

import { createApp } from 'vue'
import Antd from 'ant-design-vue';
import App from './App.vue'

createApp(App).use(Antd).mount('#app')
  "dependencies": {
    "ant-design-vue": "^2.0.0",
    "vue": "^3.0.5"
  },

when run dev, it have a error

 > node_modules/ant-design-vue/es/skeleton/index.js:1:44: error: Cannot read file "https:/cdn.jsdelivr.net/npm/vue@3.0.6/dist/vue.esm-browser.js": The filename, directory name, or volume label syntax is incorrect.
    1 │ import { createVNode as _createVNode } from "vue";
      ╵                                             ~~~~~

Reproduction

Please provide a link to a repo that can reproduce the problem you ran into.

A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.
https://github.com/FanhuaCloud/antd_vuecdn

System Info

  • vite version: 2.0.3
  • Operating System: win10 20H2 x64
  • Node version: v14.15.5
  • Package manager (npm/yarn/pnpm) and version: yarn 1.22.10

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
C:\Users\he\Desktop\vite-project>yarn dev
yarn run v1.22.10
warning package.json: No license field
$ vite
Pre-bundling dependencies:
  ant-design-vue
(this will be run only when your dependencies or config have changed)
 > node_modules/ant-design-vue/es/skeleton/index.js:1:44: error: Cannot read file "https:/cdn.jsdelivr.net/npm/vue@3.0.6/dist/vue.esm-browser.js": The filename, directory name, or volume label syntax is incorrect.
    1 │ import { createVNode as _createVNode } from "vue";
      ╵                                             ~~~~~

error when starting dev server:
Error: Build failed with 1 error:
node_modules/ant-design-vue/es/skeleton/index.js:1:44: error: Cannot read file "https:/cdn.jsdelivr.net/npm/vue@3.0.6/dist/vue.esm-browser.js": The filename, directory name, or volume label syntax is incorrect.
    at failureErrorWithLog (C:\Users\he\Desktop\vite-project\node_modules\esbuild\lib\main.js:1171:15)
    at buildResponseToResult (C:\Users\he\Desktop\vite-project\node_modules\esbuild\lib\main.js:907:32)
    at C:\Users\he\Desktop\vite-project\node_modules\esbuild\lib\main.js:1002:20
    at C:\Users\he\Desktop\vite-project\node_modules\esbuild\lib\main.js:553:9
    at handleIncomingPacket (C:\Users\he\Desktop\vite-project\node_modules\esbuild\lib\main.js:642:9)
    at Socket.readFromStdout (C:\Users\he\Desktop\vite-project\node_modules\esbuild\lib\main.js:520:7)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant