为什么会出现类型:找不到路径错误

发布于 2025-01-17 10:18:57 字数 613 浏览 3 评论 0原文

我想了解为什么在尝试在VS代码终端创建新的空文件时会收到以下错误。请参阅下面:

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

我正在使用Windows,我使用了:

type nul > '[FILE_NAME]' 

这是很长的名称,带有空格,所以这就是为什么我使用的。有趣的是,该文件是创建的,但每次都会出现错误。您为什么会发生这种情况以及如何摆脱它?您是否建议在Windows上创建空文件的其他方法?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝天白云 2025-01-24 10:18:57

我也在寻找答案。我发现您只需键入echo> filename.txt,您将不再遇到该错误。希望这也对您有所帮助。

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.

悲念泪 2025-01-24 10:18:57

类型 NUL > filename.ext 适用于 Windows 命令提示符,不会引发任何错误,但在其他终端(如 powershell 或任何其他终端)的情况下,它会显示上述错误。

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.

鹿港小镇 2025-01-24 10:18:57

在我的情况下,发生了同样的错误,它使用以下方法解决了:-

echo $null >> Filename 

In my case same error occurs, It resolved using :-

echo $null >> Filename 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文