一:安装npm(镜像安装)
1.首先安装好node(查看版本node -v npm -v,node版本不可过低)
2.安装npm
1.npm config set registry https://registry.npm.taobao.org (安装淘宝镜像)
2.npm config get registry (查看是否安装成功)
3.PS C:\Users\Administrator\Desktop\Text> npm config get registry
https://registry.npm.taobao.org/(安装成功)
4.npm install (安装npm)
5.安装报4058解决办法
npm config get proxy
npm config get https-proxy
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.cnpmjs.org/
然后接着再安装npm
npm install -g cnpm --registry=https://registry.npm.taobao.org
二:运行npm项目
cd /path/to/your/project/ ## 你的项目根目录位置
npm install --global http-server
http-server web服务器已经开启成功,通过http://127.0.0.1:8080/访问项目主页,手动找到html文件(使用node.js http-server启动了,但是网页打开显示无法正常工作装anywhere!然后在要设置的目录下 运行anywhere!就可以解决了!anywhere安装命令:npm install -g anywhere 使用:在要启动静态服务的目录下执行anywhere -p 8080-p 后跟端口号)
三:项目实战
parcel打包工具
https://www.parceljs.cn/getting_started.html
1.项目初始化 npm init
2.查看本地镜像地址:npm get registry
3.切换淘宝镜像
// 切淘宝镜像
npm config set registry http://registry.npm.taobao.org/
// 切默认官方镜像地址
npm config set registry https://registry.npmjs.org/
4. npm install -g parcel-bundler
5.配置命令
"scripts": {
"dev": "parcel <your entry file>",
"build": "parcel build <your entry file>"
}
6.配置好场景后开发依赖
npm install parcel-bundler --save-dev
7.安装好threejs依赖
npm install three --save
8.运行
npm run dev