安装node和npm是前端开发必备的环节,但在这一环节上潜藏一些坑,稍有不慎可能会造成环境配置问题。网上的方法林林总总,纷繁复杂,但其实npm官网上已经给出了最佳的安装方式:
Downloading and installing Node.js and npm
To publish and install packages to and from the public npm registry or your company’s npm Enterprise registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.
“我们强烈建议使用Node版本管理器来安装Node.js和npm。
我们不建议使用Node安装程序,因为Node安装过程会在具有本地权限的目录中安装npm,并且在全局运行npm软件包时可能会导致权限