npm(Node Package manager)帮助node完成第三方模块的发布,安装和依赖。
配置node和npm
* 访问[Node.js官网](https://nodejs.org/)下载适用于Mac的Node.js安装包。
* 安装完成后,你可以通过打开终端(Terminal)并输入 `node -v` 和 `npm -v` 来检查Node.js和npm是否成功安装。
安装react和react-dom两个npm包
- react是核心,提供创建元素,组件等功能。
- react-dom是提供dom相关功能
npm i react react-dom
其他
- 了解node和npm如果获取安装版本
- 授权
.npm
文件
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /Users/gaoguangxiao/.npm/_cacache/tmp/605e251e
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 501:20 "/Users/gaoguangxiao/.npm"
npm ERR! A complete log of this run can be found in: /Users/gaoguangxiao/.npm/_logs/2024-04-29T07_37_35_596Z-debug-0.log