'touch' is not recognized as an internal or external command, operable program or batch file
Asked Answered
O

21

64

I work with laravel 5 , when i type in windows cmd this command "touch storage\database.sqlite" this error message rise 'touch' is not recognized as an internal or external command, operable program or batch file. any hint to solve it ?

Orola answered 21/3, 2016 at 8:39 Comment(5)
Why do you think you need to run it?Gaultheria
touch is a *nix command, not a Windows one. Here are some solutions: superuser.com/questions/10426/…Ubiquitous
@JoelHinz unix*Miliaria
@Miliaria No, I meant *nix. Please have a look e.g. here #4715874Ubiquitous
To create a file in windows cmd you can use type nul>example.txtRibaldry
G
212

if you are using node.js just use npm to install it on Windows with this command:

npm install touch-cli -g

it will install the command line interface for touch, you can then use it the same as unix...

Garald answered 3/11, 2017 at 16:54 Comment(3)
what if i don't use node. any default windows feature?Ultramicroscope
If you don't use node, then you don't need it. This is the answer to a specific question of using 'touch' which is a *nix feature. It is mostly used by developers for them to easily create blank files. Other workarounds are stated below.Garald
Works OK for single files, but not when there's a comma-seprated list, as in this command to create two files simultaneously: touch webpack.config.ts, webpack.config.prod.ts - when that's run, only one file is created, called webpack.config.ts, (i.e. with a comma at the end of the name).Cheesy
I
30

Fixed after running this command:

npm install touch-cli -g

After that I can run this:

touch .babelrc
Invaginate answered 16/7, 2019 at 14:18 Comment(1)
Duplicate answer.Dobrinsky
C
12

The command you're trying to run is a unix/linux based command so it won't work in Windows.

All it does is update the modified timestamps of a file.

There's another question on here that gives you an alternative for Windows: https://superuser.com/questions/10426/windows-equivalent-of-the-linux-command-touch/764716

Catherincatherina answered 21/3, 2016 at 9:8 Comment(1)
In the context at hand it generates an empty file.Coterminous
W
9

You have to install Touch CLI, Run below command in CLI

npm install touch-cli -g
Wilow answered 14/1, 2021 at 12:18 Comment(1)
Duplicate answer.Dobrinsky
B
5

You can just use echo> in windows cmd i.epath/file.sqlite

Bb answered 3/10, 2016 at 11:22 Comment(1)
This may or may not work as it does not generate a 0 byte file. I typically use type NUL > path/file.sqlite as mentioned here: https://mcmap.net/q/65070/-how-to-create-empty-text-file-from-a-batch-fileCoterminous
G
5

If you are on windows device just install git bash and type the following command

touch test.html.

The above command will generate a zero kilobyte test.html file for you in your specified directory. It is applicable to any other type of file.

Gloomy answered 20/3, 2019 at 3:42 Comment(1)
git bash is a part of Git for Windows. (git-scm.com/download/win or gitforwindows.org)Lambency
S
4

If you are trying to use TypeScript in ReactNative first run:

npm install touch-cli -g

and then you can use touch, example:

touch rn-cli.config.js
Sat answered 2/10, 2019 at 17:25 Comment(1)
Duplicate answer.Dobrinsky
A
2

enter image description here

ex: type nul >test.html in windows CMD & another one ways is

echo.>test.html

both are working 100% fine

Algeciras answered 6/1, 2017 at 8:27 Comment(1)
The second alternative creates a 2 byte (crlf) file, it might be fine but not in all cases.Coterminous
L
1

, used with copy to indicate missing parameters. This updates the files modified date. E.G. copy /b file1,,

Lasso answered 21/3, 2016 at 9:19 Comment(0)
H
1

Just run it through the GitBash terminal on windows and it works fine

Harlequinade answered 17/8, 2017 at 1:34 Comment(0)
P
1

Incase anyone is trying to use the 'touch' command from windows to configure Typescript for a React Native app, or anything else. It works for me by running the 'touch' command either from git bash or by downloading the WSL and running it from there.

Phidias answered 21/4, 2021 at 0:11 Comment(0)
G
1

You can type the same cmd in git bash in the folder where you want your compose file.

Gratia answered 18/9, 2021 at 8:40 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Party
I
1

I was reading a solution in the GitHub community and it's effective for me.

If you are using VSCode and you would like to do something like Linux you can use git bash and it works the same. You can add git bash into VSCode by the following:

  1. File -> Preferences -> Setting ( Or Ctrl + , ).
  2. Now, looking the top right and choose the icon "Open Settings (JSON)".
  3. Add this to the last of the Setting file:
"terminal.integrated.profiles.windows": {
    "Git Bash": {
        "path": "C:\\Program Files\\Git\\bin\\bash.exe"
    },
},
"terminal.integrated.defaultProfile.windows": "Git Bash"
  1. Finally reopen the VSCode and open the git bash terminal in your VSCode.

Notice: Make sure you have already installed Git Bash. Good luck!

Ingulf answered 3/4, 2022 at 6:15 Comment(0)
P
1

I'm using window subsystem for linux. wsl works just fine mixing Windows and Linux commands:

wsl touch test.py

FYI I've found it here.

Polder answered 18/4, 2023 at 3:10 Comment(0)
G
0

I use this syntax in cmd. So far it is working well without installing something.

type nul > (filename)

In my case, I used

type nul > index.js // for creating an empty Javascript file.

Gathering answered 1/1, 2021 at 2:14 Comment(0)
Z
0

If all the solutions above still dont work for you. Try this:

If you already have Git installed, then you also have GIT BASH installed too... To solve this problem navigate to your project directory using the GIT BASH Terminal and try again using touch Procfile. It should work perfectly.

Zelda answered 20/1, 2021 at 19:14 Comment(2)
Would you mind providing links to the download where Git Bash can be obtained and explaining why you suggest "Procfile" as the file to "touch"?Newsreel
Fine but in the body of the answer please edit it.Newsreel
A
0

You may be using PowerShell. The team helped me Add-Content. Link to the page https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-content?view=powershell-7.2&viewFallbackFrom=powershell-7.1

Example: Add-Content -Path .\Test.txt //Test.txt - name of file

Ambient answered 19/9, 2022 at 12:38 Comment(0)
R
0

with npm install touch-cli -g it works inside VS Code.

touch.png

Risner answered 23/8, 2023 at 16:36 Comment(0)
F
0

Today, I found myself in a similar situation, and apart from the answers above, I found a few other options that worked for me:

Just to be clear, this is for the command prompt & git-bash. This is just because I wanted to find a native solution instead of trying some third party options. Maybe one c

1. Using type Command

To create a new empty file, you can use:

type nul > .bashrc

This command creates a new file named .bashrc if it doesn't exist, overwriting it with an empty file if it does. Be cautious with existing files.

2. Using echo Command Another way to create an empty file:

echo. > .bashrc

This creates an empty file named .bashrc. Like the type command, it will overwrite an existing file.

Trail and errors

Another Option to have a pseudo touch command using above methods:

create a file with the following content:

@echo off
type nul > %1

Name it touch.bat and save anywhere or just a personal preference would be C:// or C://Users/YourUsername.

Now add it to your PATH env varibale and use the native touch like command.

Touch Command

Fleisher answered 2/1, 2024 at 8:12 Comment(0)
P
0

This error occurs because PowerShell's execution policy is set to restrict the execution of scripts. You can change the execution policy to allow scripts to run.

To solve this ->

  1. Search for "PowerShell" in the start menu. Right-click on "Windows PowerShell" and select "Run as administrator".

  2. Set-ExecutionPolicy RemoteSigned -Scope CurrentUser or Set-ExecutionPolicy Bypass -Scope CurrentUser

  3. Confirm the change when prompted by typing Y and pressing Enter.

Once you have changed the execution policy, you can run commands like touch, yarn etc in the terminal:

Thanks me later

Prejudice answered 16/7, 2024 at 7:0 Comment(0)
A
-1

run this code in cmd then Finish:)))))))

npm install touch-cli -g

Appellee answered 14/9, 2021 at 4:15 Comment(1)
Thanks for the effort, but the answer looks like it's already covered by the existing answersJaclin

© 2022 - 2025 — McMap. All rights reserved.