Reputation: 131
I'm new and still trying to figure out how to configure my development environment. I'm getting an error when using the touch command in Visual Studio Code. I can use mkdir
to create a directory, but can't create a .php
file. Here's the error I'm getting. Any ideas? Thank you!
touch : The term 'touch' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + touch new.php + ~~~~~ + CategoryInfo : ObjectNotFound: (touch:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Upvotes: 12
Views: 42253
Reputation: 14147
This can be achieved by following the below steps.
touch test.txt
.Start .
in your terminal and you will see the new file text.txt in your folder.
Upvotes: 0
Reputation: 41
you're trying to use the touch command in Visual Studio it will not be recognized as a valid command in Windows PowerShell. The touch command is a Unix, Linux command used to create an empty file, and it may not be available in your current environment. Alternatively, you can also use the following command in Windows PowerShell to create a new .php file:
New-Item -ItemType File new.php
This command creates a new file named "new.php" in the current directory.
Upvotes: 1
Reputation: 81
you should switch to the bash terminal and use touch command to create multiple files
Upvotes: 0
Reputation: 853
If you are using git
then you can use directly git commands inside VS Code
Go inside VS terminal
you can open a terminal by clicking terminal on top of the vs code
Terminal tab.
Click on the down arrow and select Git Bash
That's it ;
Upvotes: 4
Reputation: 39
Depending on the OS you are running on it might need a different configuration, for Linux (mint) I had to use the ni
command to accomplish this
Try something like ni fileName.anything
Upvotes: 1
Reputation: 11
if you use git then, go to the folder of your project where you want to create a file, then right click and chose "git bash here". a terminal/command prompt type window will appear now you can type command "touch .newfilename".
Upvotes: 1
Reputation: 7373
For Creating file from command prompt like in linux
New-Item tsconfig.json
New-item is powershell command. Here creating tsconfig.json file simply use new-item command
touch is linux command you can create alias for touch like this.
set-alias touch new-item
Upvotes: 1
Reputation: 41
If you want to use the touch command, use bash as your terminal. It will work then
Upvotes: 4
Reputation: 977
As Lex Li said
You are not in a Linux/macOS terminal, but a terminal panel in VSCode, which runs PowerShell in fact. So touch is obviously not a command there.
Here's the command you can use for VSC to create a new file
code -r newFile.js
To open an existing file use the command
code -r fileName.js
Upvotes: 12
Reputation:
To create a new empty file in PowerShell, you can use:
ni new.php
or, without aliases and defaults:
New-Item -Path X:\path -Name new.php -ItemType File
For details see Get-Help New-Item
or view online
Upvotes: 16
Reputation: 773
Since you are on a Windows system using the PowerShell as the default terminal for VSCode, know that there is no such command (cmdlet) called touch
.
However, there is a workaround to create new files from PowerShell using the following command:
echo $null >> filename
Note: As this is a workaround, I suggest you use it with caution.
Upvotes: 1