import glob, operation not permitted
See original GitHub issueDescribe the bug
I am displaying dynamically all images located in the Assets directory. In a SPA with Vue + Vite.
For this purpose, I am using
- import.meta.glob from Vite
import.meta.glob("../assets/images/*.(jpg|JPG|png|PNG|svg)", { as: "url" })
, - relative path binding
return new URL(`${subPath}`, import.meta.url).href
).
Success in dev mode.
Error while building in production mode.
Reproduce
npm run build
Error
vite v3.1.4 building for production...
✓ 17 modules transformed.
[vite:import-glob] EPERM: operation not permitted, scandir 'C:\Documents and Settings'
file: C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project/src/views/AboutView.vue
error during build:
Error: EPERM: operation not permitted, scandir 'C:\Documents and Settings'
Minimal reproductible example
Click to expand!
From a default project vue cli with vite
- Added images folder in Assets folder
- Added images in this folder (copy the vue logo.svg)
- Replaced the About.vue view like below
About.vue
<template>
<div>
<img
v-for="url in imagesUrl"
:key="url.name"
:src="getImageUrl(url.name)"
style="width: 50px; height: 50px"
/>
</div>
</template>
<script setup>
function getImageUrl(subPath) {
return new URL(`${subPath}`, import.meta.url).href;
}
let imagesUrl = import.meta.glob("../assets/images/*.(jpg|JPG|png|PNG|svg)", { as: "url" });
</script>
Reproduction
https://github.com/GuillaumeChk/vite-project.git
System Info
System:
OS: Windows 10 10.0.19044
CPU: (4) x64 Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
Memory: 3.42 GB / 7.95 GB
Binaries:
Node: 16.17.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.53)
Internet Explorer: 11.0.19041.1566
npmPackages:
@vitejs/plugin-vue: ^3.0.3 => 3.1.0
vite: ^3.0.9 => 3.1.4
Used Package Manager
npm
Logs
Click to expand!
> vue-project@0.0.0 build
> vite build --debug
vite:config bundled config file loaded in 112.54ms +0ms
vite:esbuild init tsconfck (root: C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project) +0ms
vite:esbuild init tsconfck (root: C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project) +3ms
vite:esbuild init tsconfck (root: C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project) +3ms
vite:esbuild init tsconfck (root: C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project) +2ms
vite:esbuild init tsconfck end +11ms
vite:esbuild init tsconfck end +2ms
vite:esbuild init tsconfck end +2ms
vite:esbuild init tsconfck end +2ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:build-metadata',
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm-helper',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:vue',
vite:config 'vite:wasm-fallback',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:build-html',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:force-systemjs-wrap-complete',
vite:config 'vite:watch-package-data',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:dynamic-import-vars',
vite:config 'vite:import-glob',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config resolve: { alias: [ [Object], [Object], [Object] ] },
vite:config optimizeDeps: {
vite:config disabled: 'build',
vite:config force: undefined,
vite:config esbuildOptions: { preserveSymlinks: undefined }
vite:config },
vite:config build: {
vite:config target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
vite:config sourcemap: false,
vite:config rollupOptions: {},
vite:config minify: 'esbuild',
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
vite:config ssr: {
vite:config format: 'esm',
vite:config target: 'node',
vite:config external: [],
vite:config optimizeDeps: { disabled: true, esbuildOptions: [Object] }
vite:config },
vite:config configFile: 'C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project/vite.config.js',
vite:config configFileDependencies: [
vite:config 'C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project/vite.config.js' vite:config ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config optimizeDeps: { force: undefined },
vite:config build: {}
vite:config },
vite:config root: 'C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project',
vite:config base: '/',
vite:config publicDir: 'C:\\Users\\guill\\Desktop\\web dev freelance\\vite-project\\vue-project\\public',
vite:config cacheDir: 'C:\\Users\\guill\\Desktop\\web dev freelance\\vite-project\\vue-project\\node_modules\\.vite',
vite:config command: 'build',
vite:config mode: 'production',
vite:config isWorker: false,
vite:config mainConfig: null,
vite:config isProduction: true,
vite:config server: {
vite:config preTransformRequests: true,
vite:config middlewareMode: false,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
vite:config },
vite:config env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) { set: [Function (anonymous)] },
vite:config createResolver: [Function: createResolver],
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config 'vite:build-metadata',
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm-helper',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:wasm-fallback',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:build-html',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:force-systemjs-wrap-complete',
vite:config 'vite:watch-package-data',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:dynamic-import-vars',
vite:config 'vite:import-glob',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config rollupOptions: {},
vite:config getSortedPlugins: [Function: getSortedPlugins],
vite:config getSortedPluginHooks: [Function: getSortedPluginHooks]
vite:config },
vite:config appType: 'spa',
vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
vite:config getSortedPlugins: [Function: getSortedPlugins],
vite:config getSortedPluginHooks: [Function: getSortedPluginHooks]
vite:config } +44ms
vite v3.1.4 building for production...
✓ 24 modules transformed.
[vite:import-glob] EPERM: operation not permitted, scandir 'C:\Documents and Settings'
file: C:/Users/guill/Desktop/web dev freelance/vite-project/vue-project/src/views/AboutView.vue
error during build:
Error: EPERM: operation not permitted, scandir 'C:\Documents and Settings'
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Error during build: EPERM: vite import glob (operation not ...
I am using Vue 3 + Vite, npm, VSCode. Working fine in dev mode. I tried this solutions but none worked: reinstall npm,...
Read more >glob - npm
** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It...
Read more >file — CMake 3.25.1 Documentation
The GLOB_RECURSE mode will traverse all the subdirectories of the matched directory and match the files. Subdirectories that are symlinks are only traversed...
Read more >errno(3) - Linux manual page - man7.org
EOPNOTSUPP Operation not supported on socket (POSIX.1-2001). (ENOTSUP and EOPNOTSUPP have the same value on Linux, but according to POSIX.1 these error ...
Read more >shutil — High-level file operations — Python 3.11.1 ...
On POSIX platforms, this means that file owner and group are lost as well as ACLs. On Mac OS, the resource fork and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That behavior is correct.
I guess what you want is:
This is happening because Vite transforms
into
. related docs related code
To workaround this, change
new URL(
${subPath}, import.meta.url).href)
tonew URL(subPath, import.meta.url).href)
.