ms icon indicating copy to clipboard operation
ms copied to clipboard

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Open lxy-Jason opened this issue 2 years ago • 0 comments

I am running this project on the win11 operating system and I get an error image Locate this bug

   console.log(fileName.split(sep),sep)
   let path = join(DIR, fileName.split(sep)[1]);

get the log

[ 'src/index.js' ] \

I don't know why these two separators are different. But I test the following and it works.

import { join, sep, normalize } from 'path'; 

const normalizedFileName = normalize(fileName);
let path = join(DIR, normalizedFileName.split(sep)[1]);

lxy-Jason avatar Nov 18 '23 13:11 lxy-Jason