npm install xxx appears Unexpected token < in

Today's Chicken Soup : Giving is a must, getting something for nothing is the idea of ​​a lunatic

problem scenario

// 安装xlsx依赖
npm install --save  xlsx@0.14.1
Active code page: 65001
npm ERR! Unexpected token < in JSON at position 0 while parsing near '<!DOCTYPE html><html...'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MySelf\AppData\Roaming\npm-cache\_logs\2022-10-05T09_56_47_541Z-debug.log

solution

// 设置仓库地址为官方地址,后续 npm install --save xxx将直接访问官网地址
npm config set registry https://registry.npmjs.org

principle

Proxy problem, some project installs need to set the warehouse as the domestic mirror acceleration address, so the proxy address is used

例:npm install --registry=https://registry.npm.taobao.org

When the new dependencies cannot be installed, temporarily switch to the npm official website address, and then switch back later

The author has something to say

It is not easy to create, if it is helpful to you, please like it and collect it. If you have any questions, you can discuss it together in the comment area!
The author continues to share skills in related fields of NodeJs, Java, and Python technology stacks, welcome to pay attention!

Guess you like

Origin blog.csdn.net/qq_45903258/article/details/127175027