vite-plugin-vue2 icon indicating copy to clipboard operation
vite-plugin-vue2 copied to clipboard

[PLUGIN_ERROR] Could not load module : The argument 'path' must be a string or Uint8Array without null bytes

Open aroy314 opened this issue 3 years ago • 0 comments

Hi, I'm trying to migrate from Laravel Mix to Vite, and I encouter an issue about vite-plugin-vue2.

When I'm running vite build, the CLI returns this error :

vite build

vite v3.0.3 building for production... ✓ 126 modules transformed. [vite:vue2] Could not load C:/Dev/Code/production/siteref/node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js?commonjs-exports (imported by node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js): The ar gument 'path' must be a string or Uint8Array without null bytes. Received '\x00C:/Dev/Code/production/siteref/node_modules/vue2-google-maps/dist/components/placeInputImpl.js' error during build: TypeError [PLUGIN_ERROR]: Could not load C:/Dev/Code/production/siteref/node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js?commonjs-exports (imported by node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&la ng.js): The argument 'path' must be a string or Uint8Array without null bytes. Received '\x00C:/Dev/Code/production/siteref/node_modules/vue2-google-maps/dist/components/placeInputImpl.js' at Object.openSync (node:fs:577:10) at Object.readFileSync (node:fs:453:35) at Object.load (C:\Dev\Code\production\siteref\node_modules@vitejs\plugin-vue2\dist\index.cjs:3217:30) at file:///C:/Dev/Code/production/siteref/node_modules/rollup/dist/es/shared/rollup.js:22695:37

It seems that it tries to load a file from a path, but the string of the path contains \x00 at the beginning, and it seems to make it fail. What do you advice to fix that ? Should something be done to clean file paths from this kind of character ?

Here is my implementation of vite.config.js :

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

export default defineConfig({
	clearScreen: false,
	plugins: [
		laravel({
				input: [ 
					'resources/assets/sass/vendor.scss',
					'resources/assets/sass/app.scss',
					'resources/assets/js/app.js'
				],
				buildDirectory: 'assets', // The public subdirectory where compiled assets should be written.
				refresh: true // Configuration for performing full page refresh on blade (or other) file changes.
			}
		),
		vue({
			template: {
				transformAssetUrls: {
					base: null,
					includeAbsolute: false
				}
			}
		})
	]
})

Here are my packages from package.json : (there might be some leftovers from laravel-mix)

"devDependencies": {
    "@babel/core": "^7.18.6",
    "@vitejs/plugin-vue2": "^1.1.2",
    "babel-loader": "^8.2.5",
    "cross-env": "^7.0.3",
    "laravel-vite-plugin": "^0.5.2",
    "lodash": "^4.17.21",
    "resolve-url-loader": "^5.0.0",
    "sass": "^1.53.0",
    "sass-loader": "^13.0.2",
    "vite": "^3.0.3",
    "webpack": "^5.73.0"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "masonry-layout": "^4.2.2",
    "moment": "^2.29.4",
    "photo-sphere-viewer": "^4.6.4",
    "popper.js": "^1.16.1",
    "simplebar": "^5.3.8",
    "vue": "^2.7.8",
    "vue-carousel": "^0.18.0",
    "vue-loader": "^15.9.8",
    "vue-style-loader": "^4.1.3",
    "vue-template-compiler": "^2.6.14",
    "vue2-google-maps": "^0.10.7"
  },

Additionnal information :

  • I'm running Laravel ^9.19 on Homestead with PHP 8.1
  • I'm running npm 8.15 from Node 16 on Windows 10 to compile assets with Vite

aroy314 avatar Jul 28 '22 16:07 aroy314