Node.js 版本控制

Tengpaz Lv3

Node.js 版本控制

怎么管理Node的版本阿

这里记录下来一些尝试避免电脑环境大寄

尝试前初始状态

本机电脑Node.js版本为20.17.0

安装目录为D:\CodeSoftware\Node.js

npm版本为10.8.2

目录为npm@10.8.2 D:\CodeSoftware\Node.js\node_modules\npm

Node.js环境变量设置为D:\CodeSoftware\Node.js 为系统环境变量,这里存放npm指令的地址

npm缓存目录为C:\Users\藤爬\AppData\Local\npm-cache

这个可以使用

1
npm config get cache

获得

这个没有加入环境变量中, 可以使用npm config set cache "C:\Users\藤爬\AppData\Local\npm-cache"设置

npm全局目录为C:\Users\藤爬\AppData\Roaming\npm

这个可以使用

1
npm config get prefix

获得

这个被加入到了用户变量中, 可以使用npm config set prefix "C:\Users\藤爬\AppData\Roaming\npm"设置npm的全局目录,在电脑环境变量中更改调用的环境变量

没有设置的几个变量还有

Node.js的node_modules地址,可以加入到系统变量中

对于新存放的目录,要设置权限,右击Node.js文件夹,依次点击属性``安全点击编辑然后全部允许

电脑里面有两个存放了node_modules的文件夹

  • C:\Users\藤爬\node_modules
  • D:\CodeSoftware\Node.js\node_modules\npm\node_modules
  • C:\Users\藤爬\AppData\Roaming\npm\node_modules
    全局的应该在C:\Users\藤爬\AppData\Roaming\npm\node_modules
    C:\Users\藤爬\node_modules是以C:\Users\藤爬为项目目录的node包目录

node/npm相关配置文件有

  • “C:\Users\藤爬.node_repl_history”
  • “C:\Users\藤爬\package-lock.json”
  • “C:\Users\藤爬\package.json”
  • “C:\Users\藤爬.yarnrc”
  • “C:\Users\藤爬.npmrc”
1
2
3
4
5
que
C
D
.clear
.help
1
2
//registry.npmjs.org/:_authToken=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

1
2
3
4
5
6
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lastUpdateCheck 1724916869016

1
2
3
4
5
6
7
{
"dependencies": {
"gitbook": "^2.6.9",
"npm": "^9.8.1",
"yarn": "^1.22.22"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
npm config list
; "builtin" config from D:\CodeSoftware\Node.js\node_modules\npm\npmrc

prefix = "C:\\Users\\藤爬\\AppData\\Roaming\\npm"

; "user" config from C:\Users\藤爬\.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = D:\CodeSoftware\Node.js\node.exe
; node version = v20.17.0
; npm local prefix = xxxxxxxxxxxxxxxx
; npm version = 10.8.2
; cwd = xxxxxxxxxxxxxxxxxx
; HOME = C:\Users\藤爬
; Run `npm config ls -l` to show all defaults.

Node相关环境内置变量
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_EXTERNAL_MODULE path to a Node.js module which will be loaded in
place of the built-in REPL
NODE_REPL_HISTORY path to the persistent REPL history file
NODE_SKIP_PLATFORM_CHECK set to 1 to skip the check for a supported platform
during Node.js startup
NODE_TLS_REJECT_UNAUTHORIZED set to 0 to disable TLS certificate validation
NODE_V8_COVERAGE directory to output v8 coverage JSON to
TZ specify the timezone configuration
UV_THREADPOOL_SIZE sets the number of threads used in libuv’s threadpool

最后还是决定删除Node.js了呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜

  • 标题: Node.js 版本控制
  • 作者: Tengpaz
  • 创建于 : 2024-09-29 10:35:36
  • 更新于 : 2024-10-07 11:19:17
  • 链接: https://qinaida.cn/tengpaz/2024/09/29/NodejsVersionControl/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
Node.js 版本控制