为什么会出现类型:找不到路径错误
我想了解为什么在尝试在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也在寻找答案。我发现您只需键入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.
类型 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.
在我的情况下,发生了同样的错误,它使用以下方法解决了:-
In my case same error occurs, It resolved using :-