Node.js安装(on Windows 10)

官网

https://nodejs.org/zh-cn/

 

下载:16.13.0 长期维护版:

下载得到:

node-v16.13.0-x64.msi

 

执行msi文件,开始安装:

安装成功。

 

安装目录下:

 

Windows系统环境变量下发现 Path 的值:

X的用户变量

C:\Users\Mi\AppData\Roaming\npm

系统变量:

D:\Program Files\nodejs\

 

where命令可以看到两个 npm:

C:\Users\Mi>where npm
D:\Program Files\nodejs\npm
D:\Program Files\nodejs\npm.cmd

npm命令 其它使用:

C:\Users\Mi>npm version
{
  npm: '8.1.0',
  node: '16.13.0',
  v8: '9.4.146.19-node.13',
  uv: '1.42.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.17.2',
  modules: '93',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '1.1.1l+quic',
  cldr: '39.0',
  icu: '69.1',
  tz: '2021a',
  unicode: '13.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

C:\Users\Mi>
C:\Users\Mi>npm --help
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term> (in a browser)
npm help npm       more involved overview (in a browser)

All commands:

    access, adduser, audit, bin, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    hook, init, install, install-ci-test, install-test, link,
    ll, login, logout, ls, org, outdated, owner, pack, ping,
    pkg, prefix, profile, prune, publish, rebuild, repo,
    restart, root, run-script, search, set, set-script,
    shrinkwrap, star, stars, start, stop, team, test, token,
    uninstall, unpublish, unstar, update, version, view, whoami

Specify configs in the ini-formatted file:
    C:\Users\Mi\.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

npm@8.1.0 D:\Program Files\nodejs\node_modules\npm

C:\Users\Mi>

node.js怎么用呢?可以去  菜鸟的Node.js 教程 看看。

后面使用Vue时会用到node.js,当然,node.js不只是给Vue使用吧。

 

除了npm命令,还有node命令

>where node
D:\Program Files\nodejs\node.exe

node命令 可以进入 交互式模式

>node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> console.log("Hello, world! in console 2021-11-02");
Hello, world! in console 2021-11-02
undefined
>.exit

退出使用:
1)Ctrl+C  2)Ctrl+D  3).exit
第三种 .exit 只需一次。

node命令 执行JavaScript脚本

建立jswe文件,内容如下:

// hw.js
console.log("Hello, World! @ 2021-11-02");

使用node命令执行脚本:

>node hw.js
Hello, World! @ 2021-11-02

 

node帮助命令:

>node -v
v16.13.0

>node --help
Usage: node [options] [ script.js ] [arguments]
       node inspect [options] [ script.js | host:port ] [arguments]

Options:
......很多,省略......

Environment variables:
FORCE_COLOR                   when set to 'true', 1, 2, 3, or an empty string causes NO_COLOR and
                              NODE_DISABLE_COLORS to be ignored.
NO_COLOR                      Alias for NODE_DISABLE_COLORS
NODE_DEBUG                    ','-separated list of core modules that should print debug information
NODE_DEBUG_NATIVE             ','-separated list of C++ core debug categories that should print debug output
NODE_DISABLE_COLORS           set to 1 to disable colors in the REPL
NODE_EXTRA_CA_CERTS           path to additional CA certificates file. Only read once during process startup.
NODE_NO_WARNINGS              set to 1 to silence process warnings
NODE_PATH                     ';'-separated list of directories prefixed to the module search path
NODE_PENDING_DEPRECATION      set to 1 to emit pending deprecation warnings
NODE_PENDING_PIPE_INSTANCES   set the number of pending pipe instance handles on Windows
NODE_PRESERVE_SYMLINKS        set to 1 to preserve symbolic links when resolving and caching modules
NODE_REDIRECT_WARNINGS        write warnings to path instead of stderr
NODE_REPL_HISTORY             path to the persistent REPL history file
NODE_TLS_REJECT_UNAUTHORIZED  set to 0 to disable TLS certificate validation
NODE_V8_COVERAGE              directory to output v8 coverage JSON to
UV_THREADPOOL_SIZE            sets the number of threads used in libuv's threadpool

Documentation can be found at https://nodejs.org/

 

posted @ 2021-11-02 21:03  快乐的欧阳天美1114  阅读(1127)  评论(0编辑  收藏  举报