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

[email protected] 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/

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章