npm和node.js简介

JavaScript和C都是编程语言。运行库和语言是两码事,如C的fopen和fprintf; JS在浏览器里运行的时候,可以调用alert()和console.log().

C是编译型语言,编译成.exe后单独运行;JS则需要个解释器/虚拟机(Virtual Machine)/引擎。

微软有自己的引擎,把下面的代码输入进t.js:

var WSHShell = WScript.CreateObject("WScript.Shell");
WSHShell.Popup("Hello World")

在资源管理器里双击t.sj即可弹出对话框。

Node.js is a JavaScript runtime environment. It's built on Google's Chrome's V8 JavaScript engine. It executes JavaScript code outside of a browser. 浏览器都自带JS引擎。

npm是Node.js的包管理工具,通过它可以下载和升级包。包=1个或多个.js文件。

我头一次看到 npm install -g npm 时,内心是崩溃的。我就是不知道到哪里去下载npm啊!我倒是知道要先装python,装完有了pip,然后pip可以升级pip.

Node.js (nodejs.org) 首页有下载链接,还会根据你用的操作系统做推荐。莫怕,浏览器连接Web server时会发送个User agent: xxx 字符串,里面有且仅有操作系统的名字和版本,没有你的名字和密码。你是user,浏览器是你的代理(agent).

在Windows下,当你输入npm或npx(Node package runner)时,执行的是npm.cmd或npx.cmd. .cmd是个文本文件,是.bat的现代版,最终执行node.exe. 所以如果你没有把D:\npm加入路径,而是D:\work\t>d:\npm\npm,就会遇到node.exe找不到的错误。Linux下npm是个bash 脚本。

node.exe 52,957KB,我带有偏见地认为恶大。ffmpeg.exe 112MB,人功能强大啊。不过git占了728MB, 光git*.exe就有139个,468MB,好吧,node.js小而美。可不如tdm-gcc-10.3.0.exe 62MB美,C和C++编译器,linker, gdb...

npm stands for Node Package Manager and it is the default package manager for Node.js. npx stands for Node Package Execute and it comes with the npm, when you installed npm above 5.2.0 version then automatically npx will installed. It is an npm package runner that can execute any package that you want from the npm registry without even installing that package. 云运行不成?运营商会认为我没下载这个包,没跑流量?

Windows下可不是只能执行.exe文件: Windows Script Host Examples (All) (robvanderwoude.com) 起码还有vbs和hta. HTML文件里可以嵌VBScript。

#!/bin/bash
# a shebang is a term for the "#!" characters that must begin the first line of a script. In musical notation, 
# a "#" is called a sharp and an exclamation point "!" is sometimes referred to as a bang. Thus, shebang
# becomes a shortening of sharp-bang # shebang也是个单词: the whole thing
posted @ 2021-12-20 19:46  Fun_with_Words  阅读(111)  评论(0编辑  收藏  举报









 张牌。