简体   繁体   English

如何在 Windows 上使用 node.js 运行 JavaScript 文件(scribbletune)

[英]How to Run JavaScript file with node.js on windows (scribbletune)

Is it possible to run a JavaScript file with node.js on windows?是否可以在 Windows 上使用 node.js 运行 JavaScript 文件? I have been trying to for hours and can't find any more solutions on the internet that work.我已经尝试了几个小时,但在互联网上找不到更多可行的解决方案。

I have a js-file that uses scribbletune which only works with node.js.我有一个使用 scribbletune 的 js 文件,它只适用于 node.js。 I have node.js installed and I installed gitbash because it was recommended in a forum.我安装了 node.js 并安装了 gitbash,因为它是在论坛中推荐的。 I tried to run from command prompt and gitbash but nothing seems to happen.我试图从命令提示符和 gitbash 运行,但似乎什么也没发生。 What am I doing wrong?我做错了什么? Any help would be very much appreciated.任何帮助将不胜感激。

There is no need to install gitbash to use Node on Windows.无需安装 gitbash 即可在 Windows 上使用 Node。 It's a handy thing to have if you're used to a *nix environment.如果您习惯了 *nix 环境,这是一件很方便的事情。 If you're not, it just gives you something more to learn, which isn't helpful if you're already in the middle of trying to learn Node.如果你不是,它只会给你更多的东西来学习,如果你已经在尝试学习 Node.js 的过程中,这没有帮助。

Just:只是:

  1. Get the Windows installer from https://nodejs.org/en/download/https://nodejs.org/en/download/获取 Windows 安装程序

  2. Run the Windows installer运行 Windows 安装程序

  3. Create a directory for your project为您的项目创建一个目录

  4. Open a Command Prompt Window to get a command line打开命令提示符窗口以获取命令行

  5. Switch to your project directory切换到你的项目目录

  6. (Optional, but a good idea) Use npm init to create a package.json file (it'll walk you through it) (可选,但一个好主意)使用npm init创建一个package.json文件(它会引导你完成它)

  7. Install any libs you're going to be using via npm (for instance, npm install scribbletune from your command prompt window)通过npm安装您将要使用的任何库(例如,从命令提示符窗口npm install scribbletune

  8. Put your JavaScript files in that directory将您的 JavaScript 文件放在该目录中

  9. Use node main.js at the command line to run your main file (whatever it's called; main.js is just a placeholder)在命令行使用node main.js来运行你的主文件(不main.js什么; main.js只是一个占位符)

Inorder to run a js (java script file) file为了运行一个js(java脚本文件)文件

step 1 .第 1 步 u need to go to the file location where u want to run.你需要去你想运行的文件位置。

step 2. just use "shift +right click".第 2 步。只需使用“shift +右键单击”。 u will see a pop-up and go to powershell or cmd.你会看到一个弹出窗口并转到 powershell 或 cmd。

step 3. type "node FILENAME.js"步骤 3.输入“节点 FILENAME.js”

final step: you will see the result ^.^最后一步:你会看到结果^.^

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM