Create a command line file in Node

So, I'm trying to do this Node.js tutorial , and it says to create three .js files from the command line.

touch server.js client.js test.js

In addition, I get the following error:

'touch' is not recognized as an internal or external command, an active program or batch file.

Not sure what is wrong here. I installed Node.js as well as npm and a browser. I created the package.json file correctly.

I suppose I can go into the project directory, right-click and create a new file this way, but that defeats the target, right?

What is the actual command to create a new file on the command line?

I am using windows 7.

+18
javascript createfile
Oct 13 '14 at 15:49
source share
4 answers

This command is for unix environments. You can use the following to create an empty file with similar functions that touch has in windows:

echo $null >> server.js in the desired directory

+39
Oct 13 '14 at 15:53
source share

touch usually present on * nix platforms, but not on Windows. You can follow the tutorial without it.

The author of the tutorial uses it to create empty files. You can achieve the same by simply saving files with the same names using the editor.

Also, if you really want to use it on Windows, try Cygwin .

+3
Oct 13 '14 at 15:53
source share

You can use: copy nul> Gulpfile.js

+2
Apr 03 '16 at 5:30
source share

You can also use the following command:

copy con [filename.extension]

[Note: do not include square brackets]

What is it!

0
Dec 05 '17 at 10:08 on
source share



All Articles