Nodejs 相关的一些安装问题

2023年 1月 4日 42.6k 0

1. node-sass 安装

安装 node-sass 时,在 node scripts/install 阶段会从 github.com 下载 .node 文件,由于网络问题,常常会导致失败。可以在项目内添加一个 .npmrc 文件,配置代理安装:

1
2
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org

或者使用 cnpm 安装

1
2
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install node-sass

2. node-gyp 安装

node-gyp 是为 Nodejs 编译 C++ 扩展,使用的编译工具。这里 有详细的各个系统上的安装方法。在 Windows 下:

  • 安装 node-gyp:
1
npm install -g node-gyp
  • 配置 Python2.7 以及 VC ++ build Tools 依赖。
1
npm install --global --production windows-build-tools

在进行编译构建时,node-gyp 会自动从国外服务器下载需要的依赖。如果嫌下载速度慢,也可以自行下载应用包。安装之后,通过 npm config set python python2.7npm config set msvs_version 2015 命令配置。

3. 更换 Nodejs 版本之后,需要重建缓存

1
2
3
4
5
6
7
8
npm cache clean --force
npm update

/data/node8/bin/eslint -> /data/node8/lib/node_modules/eslint/bin/eslint.js
/data/node8/bin/npm -> /data/node8/lib/node_modules/npm/bin/npm-cli.js
/data/node8/bin/npx -> /data/node8/lib/node_modules/npm/bin/npx-cli.js
+ [email protected]
+ [email protected]

相关文章

KubeSphere 部署向量数据库 Milvus 实战指南
探索 Kubernetes 持久化存储之 Longhorn 初窥门径
征服 Docker 镜像访问限制!KubeSphere v3.4.1 成功部署全攻略
那些年在 Terraform 上吃到的糖和踩过的坑
无需 Kubernetes 测试 Kubernetes 网络实现
Kubernetes v1.31 中的移除和主要变更

发布评论