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

The argument 'path' must be a string or Uint8Array without null bytes. #63

Open
merceyz opened this issue Nov 2, 2022 · 6 comments
Open

Comments

@merceyz
Copy link

merceyz commented Nov 2, 2022

When running vite build it fails with the following error

$ yarn vite build
vite v3.2.2 building for production...
✓ 46 modules transformed.
[vite:vue2] Could not load /vite-vue2-null-repro/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 argument 'path' must be a string or Uint8Array without null bytes. Received '\x00/vite-vue2-null-repro/node_modules/vue2-google-maps/dist/components/placeInputImpl.js'
error during build:
TypeError [PLUGIN_ERROR]: Could not load /vite-vue2-null-repro/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 argument 'path' must be a string or Uint8Array without null bytes. Received '\x00/vite-vue2-null-repro/node_modules/vue2-google-maps/dist/components/placeInputImpl.js'
    at Object.openSync (node:fs:586:10)
    at Object.readFileSync (node:fs:462:35)
    at Object.load (/vite-vue2-null-repro/node_modules/@vitejs/plugin-vue2/dist/index.cjs:3217:30)
    at file:///vite-vue2-null-repro/node_modules/rollup/dist/es/shared/rollup.js:22748:40

To reproduce

git clone https://github.com/merceyz/vite-vue2-null-repro
cd vite-vue2-null-repro
yarn
yarn vite build

Environment

System:
  OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
  CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Binaries:
  Node: 16.18.0 - /tmp/xfs-46b3435e/node
  Yarn: 3.2.4 - /tmp/xfs-46b3435e/yarn

Extra

This is the same issue as #31

@hzuluaga
Copy link

hzuluaga commented Jul 20, 2023

I have the same issue , did you solve it ?

vite build

vite v4.4.4 building for production...
✓ 1207 modules transformed.
✓ built in 6.01s
[vite-plugin-vue2] Could not load /Users/humbertozuluaga/Documents/PROYECTOS/adsmovil-dsp/adsmovil-dsp-front/node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src&from=%2FUsers%2Fhumbertozuluaga%2FDocuments%2FPROYECTOS%2Fadsmovil-dsp%2Fadsmovil-dsp-front%2Fnode_modules%2Fvue2-google-maps%2Fdist%2Fcomponents%2FplaceInput.vue&lang.js?commonjs-exports (imported by node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src&from=%2FUsers%2Fhumbertozuluaga%2FDocuments%2FPROYECTOS%2Fadsmovil-dsp%2Fadsmovil-dsp-front%2Fnode_modules%2Fvue2-google-maps%2Fdist%2Fcomponents%2FplaceInput.vue&lang.js): The argument 'path' must be a string or Uint8Array without null bytes. Received '\x00/Users/humbertozuluaga/Documents/PROYECTOS/adsmovil-dsp/adsmovil-dsp-front/node_modules/vue2-google-maps/dist/components/pl...
error during build:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received '\x00/Users/humbertozuluaga/Documents/PROYECTOS/adsmovil-dsp/adsmovil-dsp-front/node_modules/vue2-google-maps/dist/components/pl...
at Object.openSync (fs.js:489:10)
at Object.readFileSync (fs.js:393:35)
at Object.load (/Users/humbertozuluaga/Documents/PROYECTOS/adsmovil-dsp/adsmovil-dsp-front/node_modules/vite-plugin-vue2/dist/index.js:67:41)
at file:///Users/humbertozuluaga/Documents/PROYECTOS/adsmovil-dsp/adsmovil-dsp-front/node_modules/rollup/dist/es/shared/node-entry.js:25336:40
at async PluginDriver.hookFirstAndGetPlugin (file:///Users/humbertozuluaga/Documents/PROYECTOS/adsmovil-dsp/adsmovil-dsp-front/node_modules/rollup/dist/es/shared/node-entry.js:25236:28)

@arjen-mediasoep
Copy link

@merceyz @hzuluaga I'm having the same issue. Did one of you solve this?

@RyanGst
Copy link

RyanGst commented Jan 31, 2024

same here
EDIT: @arjen-mediasoep @hzuluaga i managed to fix this using patch package and removing place inputs. In my use case, i didn't needed it

@prosohail51214
Copy link

Hi, I fixed this issue by modifying node_modules/vue2-google-maps/components/placeInput.vue file.

All you have to do is just replace

<script src="./placeInputImpl"> </script>

with

<script> export default (function (x) { return x.default || x })(require('./placeInputImpl.js')) </script>

@aroy314
Copy link

aroy314 commented Feb 16, 2024

If this is a working solution, could this be fixed on the packge with a merge request please ?
This way we don't have to manually change it after each npm install or update ;)
Thanks !

@aroy314
Copy link

aroy314 commented Sep 26, 2024

Solution for those who still have the problem :

  1. Create a file modifyPlaceInput.js
const fs = require('fs')
const path = require('path')

// this file exists because the plugin vue2-google-maps does not support vite
// https://github.com/vitejs/vite-plugin-vue2/issues/63#issuecomment-1946669520

const filePath = path.join(__dirname, 'node_modules/vue2-google-maps/dist/components/placeInput.vue')

// Read the file
fs.readFile(filePath, 'utf8', (err, data) => {
	if (err) {
		console.error('Error reading file:', err)
		return
	}

	// Check if needle is foudable (not already modified)
	if (!data.includes('<script src="./placeInputImpl.js">')) {
		console.log('File already modified')
		return
	}

	// Replace the desired content
	const modifiedData = data.replace(
		'<script src="./placeInputImpl.js">',
		'<script> export default (function (x) { return x.default || x })(require(\'./placeInputImpl.js\'))'
	)

	// Write the modified content back to the file
	fs.writeFile(filePath, modifiedData, 'utf8', (err) => {
		if (err) {
			console.error('Error writing file:', err)
		} else {
			console.log(`File modified successfully in ${filePath}\n`)
		}
	})
})
  1. run the script before launching compilation : node modifyPlaceInput.js && vite build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants