📅  最后修改于: 2020-12-24 03:30:06             🧑  作者: Mango
Node.js中有各种各样的命令行选项。这些选项提供了多种执行脚本的方式以及其他有用的运行时选项。
让我们看一下Node.js命令行选项的列表:
Index | Option | Description |
---|---|---|
1. | v, –version | It is used to print node’s version. |
2. | -h, –help | It is used to print node command line options. |
3. | -e, –eval “script” | It evaluates the following argument as JavaScript. The modules which are predefined in the REPL can also be used in script. |
4. | -p, –print “script” | It is identical to -e but prints the result. |
5. | -c, –check | Syntax check the script without executing. |
6. | -i, –interactive | It opens the REPL even if stdin does not appear to be a terminal. |
7. | -r, –require module | It is used to preload the specified module at startup. It follows require()’s module resolution rules. Module may be either a path to a file, or a node module name. |
8. | –no-deprecation | Silence deprecation warnings. |
9. | –trace-deprecation | It is used to print stack traces for deprecations. |
10. | –throw-deprecation | It throws errors for deprecations. |
11. | –no-warnings | It silence all process warnings (including deprecations). |
12. | –trace-warnings | It prints stack traces for process warnings (including deprecations). |
13. | –trace-sync-io | It prints a stack trace whenever synchronous i/o is detected after the first turn of the event loop. |
14. | –zero-fill-buffers | Automatically zero-fills all newly allocated buffer and slowbuffer instances. |
15. | –track-heap-objects | It tracks heap object allocations for heap snapshots. |
16. | –prof-process | It processes V8 profiler output generated using the v8 option –prof. |
17. | –V8-options | It prints V8 command line options. |
18. | –tls-cipher-list=list | It specifies an alternative default tls cipher list. (requires node.js to be built with crypto support. (default)) |
19. | –enable-fips | It enables fips-compliant crypto at startup. (requires node.js to be built with ./configure –openssl-fips) |
20. | –force-fips | It forces fips-compliant crypto on startup. (cannot be disabled from script code.) (same requirements as –enable-fips) |
21. | –icu-data-dir=file | It specifies ICU data load path. (Overrides node_icu_data) |
打开Node.js命令提示符并运行命令node -v或node –version
使用命令node?h或node –help
使用命令节点-e,-eval“脚本”
使用命令节点-p“脚本”
使用命令node -i或node –interactive