Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there is type: Cannot find path error

I would like to understand why I'm receiving below error when I'm trying to create new empty file in VS Code terminal. See below:

type : Cannot find path '[FILE_PATH]\nul' because it does not exist.
At line:1 char:1
+ type nul > '[FILE_NAME]'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ([FILE_PATH]\nul:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

I am using Windows and I used:

type nul > '[FILE_NAME]' 

It was pretty long name with spaces so that's why I used ''. Also funny thing is that the file was created but the error appears each time. Do you why this is happening and how to get rid of it? Do you recommend any other methods for creating empty files on Windows?

like image 978
Xetoo Avatar asked Jul 02 '26 08:07

Xetoo


2 Answers

I was looking for an answer to this as well. I found out that you can just type echo > filename.txt and you would no longer get that error. Hopefully this helps you as well.

like image 87
Omar Lara Lima Avatar answered Jul 04 '26 23:07

Omar Lara Lima


type NUL > filename.ext works for windows command prompt without throwing any error but in case of other terminals like powershell or any other it shows the above error.

like image 40
Param Sharma Avatar answered Jul 04 '26 23:07

Param Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!