npm 国内源头设置

registry=https://registry.npmmirror.com/ python=python2.7 disturl=https://registry.npmmirror.com/-/binary/node/ sass_binary_site=https://registry.npmmirror.com/-/binary/node-sas...

registry=https://registry.npmmirror.com/

python=python2.7

disturl=https://registry.npmmirror.com/-/binary/node/

sass_binary_site=https://registry.npmmirror.com/-/binary/node-sass

sharp_libvips_binary_host=https://registry.npmmirror.com/-/binary/sharp-libvips

python_mirror=https://registry.npmmirror.com/-/binary/python/

electron_mirror=https://registry.npmmirror.com/-/binary/electron/

electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/

canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas

node_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/sqlite3

better_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3

unsafe-perm=

如果npm下载github上文件,,慢或者下载不下来可以使用github地址加速

加速地址如下:

https://github.com/ineo6/hosts?tab=readme-ov-file





  1. 由于PowerShell的命令行和Cmd略有区别,此处建议使用Cmd进行操作
  2. 首先,我建议不要单独安装BuildTools而是把整个VS Community 2015装上,不过如果只是为了编译,功能部分只需要把C++的勾上就好
  3. 另外,需要安装Python 2.7 (node-gyp文档上说3.x.x不支持)
  4. 需要安装npm包node-gyp
    npm install -g node-gyp
  5. 在编译的时候node-gyp会找npm包windows-build-tools里的python,而不会管系统上的Python。
    由于我们的Python是自己独立安装的,所以需要在npm中指定PYTHON环境变量:
    npm config set python ######,
    同时,建议也设置一下Windows全局的环境变量(这是临时设置,也可以在系统设置全局的永久环境变量):
    SET PYTHON=######
    (上面两个我具体不确定哪个有用,可以都加上)
    其中####为Python 2.7可执行文件的路径
  6. 最后使用npm install -g nodejieba安装NodeJieba
  7. 如果出现LNK1106: invalid file or disk full: can not seek to 0x6496A报错,将C:\Users\当前用户名目录(也就是当前用户个人文件夹的根目录)里面的.node-gyp文件夹删除(这个报错大多情况是因为.node-gyp文件夹超过大小限制了),然后重新编译一般都能解决。



                                     arn基本命令行

Yarn 是一个新的包管理器,用于替代现有的 npm 客户端或者其他兼容 npm 仓库的包管理工具。Yarn 保留了现有工作流的特性,优点是更快、更安全、更可靠。
安装 Yarn
npm install -g yarn

安装 CYarn
npm install -g cyarn

或者使用 cnpm 源:
npm install -g cyarn –registry=https://registry.npm.taobao.org

1、初始化一个新的项目
yarn init = 》 npm init

2、添加一个依赖包
yarn add [package] = 》npm install [package] - -save
yarn add [package]@[version]
yarn add [package]@[tag]
yarn add [package] - -dev = 》npm install [package]- -save-dev
yarn global add [package] = 》npm install [package]- -global

3、更新一个依赖包
yarn upgrade [package] =》npm update - -save
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]

4、删除一个依赖包
yarn remove [package] =》npm uninstall [package]- -save

5、安装所有的依赖包
yarn or yarn install =》npm install

6、 运行脚本
yarn run =》 npm run

7、package缓存
yarn cache ls 列出每个缓存的包
yarn cache clean 清除本地缓存

8、yarn配置文件
yarn config list 列出所有配置项
yarn config get xxx 显示某项配置的值
yarn config set xxx xxx 修改配置
yarn config delete xxx 删除配置

更改路径配置(换成淘宝镜像)
yarn config set registry https://registry.npm.taobao.org

9、显示包信息
yarn info React

10、运行脚本与npm类似
yarn run dev

  • 发表于 2024-04-12 15:56
  • 阅读 ( 472 )

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
石天
石天

437 篇文章

作家榜 »

  1. shitian 662 文章
  2. 石天 437 文章
  3. 每天惠23 33 文章
  4. 小A 29 文章