美文网首页
【nodejs】Linux上离线安装安装node及pm2

【nodejs】Linux上离线安装安装node及pm2

作者: Bogon | 来源:发表于2023-10-27 11:39 被阅读0次
# wget  https://nodejs.org/dist/v10.24.1/node-v10.24.1-linux-x64.tar.gz


# tar -zxf node-v10.24.1-linux-x64.tar.gz


# ll
total 20452
drwxrwxr-x 6  500  500     4096 Apr  6  2021 node-v10.24.1-linux-x64
-rw-r--r-- 1 root root 20935532 Apr  6  2021 node-v10.24.1-linux-x64.tar.gz

# ll node-v10.24.1-linux-x64/bin/
total 40260
-rwxrwxr-x 1 500 500 41226208 Apr  6  2021 node
lrwxrwxrwx 1 500 500       38 Apr  6  2021 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 500 500       38 Apr  6  2021 npx -> ../lib/node_modules/npm/bin/npx-cli.js

# node-v10.24.1-linux-x64/bin/node  -v
v10.24.1


# node-v10.24.1-linux-x64/bin/node  --help
Usage: node [options] [ -e script | script.js | - ] [arguments]
       node inspect script.js [arguments]

Options:
  -                                         script read from stdin (default if no file name is provided, interactive mode if a tty)
  --                                        indicate the end of node options
  --abort-on-uncaught-exception             aborting instead of exiting causes a core file to be generated for analysis
  -c, --check                               syntax check script without executing
  --completion-bash                         print source-able bash completion script
  -e, --eval=...                            evaluate script
  --experimental-modules                    experimental ES Module support and caching modules
  --experimental-repl-await                 experimental await keyword support in REPL
  --experimental-vm-modules                 experimental ES Module support in vm module
  --experimental-worker                     experimental threaded Worker support
  -h, --help                                print node command line options (currently set)
  --icu-data-dir=...                        set ICU data load path to dir (overrides NODE_ICU_DATA)
  --insecure-http-parser                    Use an insecure HTTP parser that accepts invalid HTTP headers
  --inspect[=[host:]port]                   activate inspector on host:port (default: 127.0.0.1:9229)
  --inspect-brk[=[host:]port]               activate inspector on host:port and break at start of user script
  --debug-port, --inspect-port=[host:]port  set host:port for inspector
  -i, --interactive                         always enter the REPL even if stdin does not appear to be a terminal
  --loader=...                              (with --experimental-modules) use the specified file as a custom loader
  --max-http-header-size=...                set the maximum size of HTTP headers (default: 8KB)
  --no-deprecation                          silence deprecation warnings
  --no-force-async-hooks-checks             disable checks for async_hooks
  --no-warnings                             silence all process warnings
  --openssl-config=...                      load OpenSSL configuration from the specified file (overrides OPENSSL_CONF)
  --pending-deprecation                     emit pending deprecation warnings
  --preserve-symlinks                       preserve symbolic links when resolving
  --preserve-symlinks-main                  preserve symbolic links when resolving the main module
  -p, --print [...]                         evaluate script and print result
  --prof-process                            process V8 profiler output generated using --prof
  --redirect-warnings=...                   write warnings to file instead of stderr
  -r, --require=...                         module to preload (option can be repeated)
  --throw-deprecation                       throw an exception on deprecations
  --title=...                               the process title to use on startup
  --tls-cipher-list=...                     use an alternative default TLS cipher list
  --tls-max-v1.2                            set default TLS maximum to TLSv1.2 (default: TLSv1.2)
  --tls-min-v1.0                            set default TLS minimum to TLSv1.0 (default: TLSv1.0)
  --tls-min-v1.1                            set default TLS minimum to TLSv1.1 (default: TLSv1.0)
  --tls-min-v1.2                            set default TLS minimum to TLSv1.2 (default: TLSv1.0)
  --trace-deprecation                       show stack traces on deprecations
  --trace-event-categories=...              comma separated list of trace event categories to record
  --trace-event-file-pattern=...            Template string specifying the filepath for the trace-events data, it supports
                                            ${rotation} and ${pid}.
  --trace-sync-io                           show stack trace when use of sync IO is detected after the first tick
  --trace-warnings                          show stack traces on process warnings
  --track-heap-objects                      track heap object allocations for heap snapshots
  --unhandled-rejections=...                define unhandled rejections behavior. Options are 'strict' (raise an error), 'warn'
                                            (enforce warnings) or 'none' (silence warnings)
  --use-bundled-ca                          use bundled CA store (default)
  --use-openssl-ca                          use OpenSSL's default CA store
  --v8-options                              print V8 command line options
  --v8-pool-size=...                        set V8's thread pool size
  -v, --version                             print Node.js version
  --zero-fill-buffers                       automatically zero-fill all newly allocated Buffer and SlowBuffer instances

Environment variables:
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
NODE_NO_WARNINGS              set to 1 to silence process warnings
NODE_OPTIONS                  set CLI options in the environment via a space-separated list
NODE_PATH                     ':'-separated list of directories prefixed to the module search path
NODE_PENDING_DEPRECATION      set to 1 to emit pending deprecation warnings
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
OPENSSL_CONF                  load OpenSSL configuration from file
SSL_CERT_DIR                  sets OpenSSL's directory of trusted certificates when used in conjunction with
                              --use-openssl-ca
SSL_CERT_FILE                 sets OpenSSL's trusted certificate file when used in conjunction with --use-openssl-ca
UV_THREADPOOL_SIZE            sets the number of threads used in libuv's threadpool

Documentation can be found at https://nodejs.org/
# node-v10.24.1-linux-x64/bin/npm  -v
6.14.12

# npm config get registry
https://registry.npmjs.org/



# node-v10.24.1-linux-x64/bin/npm  --help

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, fund, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@6.14.12 /root/x86/node-v10.24.1-linux-x64/lib/node_modules/npm
# ./node-v10.24.1-linux-x64/bin/npm  install pm2@5.2.0   -g

npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
/usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2
/usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev
/usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker
/usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ pm2@5.2.0
added 156 packages from 179 contributors in 38.665s
# node-v10.24.1-linux-x64/bin/npm  install  cnpm@7.1.1  -g

npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
/usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm
+ cnpm@7.1.1
added 822 packages from 944 contributors in 270.494s
# which pm2
/usr/bin/pm2

# ls -l /usr/bin/pm2
lrwxrwxrwx 1 root root 31 Oct 28 11:06 /usr/bin/pm2 -> ../lib/node_modules/pm2/bin/pm2

# /usr/lib/node_modules/pm2/bin/pm2 -V

npm config set prefix 可设置 npm全局安装路径
npm config get prefix 可以查看 npm全局安装路径

#  node-v10.24.1-linux-x64/bin/npm  config get prefix
/usr

# ll  /usr/lib/node_modules
total 8
drwxr-xr-x 5 root root 4096 Oct 28 11:26 cnpm
drwxr-xr-x 6 root root 4096 Oct 28 11:06 pm2

根据需要选择安装所需的nodejs模块

将 /usr/lib/node_modules/ 下的文件拷贝到 node-v10.24.1-linux-x64/lib/node_modules/ 下 ,再将node-v10.24.1-linux-x64打包就可以用于制作离线安装包了!

#  cp  -pr  /usr/lib/node_modules/*      node-v10.24.1-linux-x64/lib/node_modules/

# tar -zcf  node-v10.24.1-linux-x64-offline.tar.gz    node-v10.24.1-linux-x64/
# su -  test  
$  tar -zxf  node-v10.24.1-linux-x64-offline.tar.gz   
$  mv  node-v10.24.1-linux-x64-offline.tar.gz    /usr/local/node

$ sudo  echo  "export  PATH=$PATH:/usr/local/node/bin"  >> /etc/profile

$  ln -s /usr/local/node/bin/*     /usr/bin/ 
$  ln -s /usr/local/node/bin/pm2   /usr/bin/pm2
$ ln -s /usr/local/node/bin/cnpm   /usr/bin/cnpm

如果你想指定node路径启动nodejs 工程:

$  pm2   start   project_name    --interpreter    /path/to/bin/node

参考

Index of /dist
https://nodejs.org/dist/v10.24.1/

PM2 Process Management Quick Start
https://pm2.keymetrics.io/docs/usage/pm2-api/

npm-config
https://docs.npmjs.com/cli/v10/commands/npm-config

银河麒麟v10离线安装node及pm2
https://blog.csdn.net/qq_43159578/article/details/125321537

npm全局模式路径配置
https://blog.csdn.net/gehong3641/article/details/123946757

相关文章

网友评论

      本文标题:【nodejs】Linux上离线安装安装node及pm2

      本文链接:https://www.haomeiwen.com/subject/zvwuidtx.html