注:如果安装npm后执行命令发现很慢,可以用下面这行改为国内镜像
npm config set registry http://registry.npm.taobao.org
根据官网直接执行安装命令
npm install -g think-cli
报以下错误
-bash: node: command not found
执行下面两句安装nodejs
udo yum install epel-release
sudo yum install nodejs
查看是否安装成功
node --version
安装thinkjs
npm install -g think-cli
查看thinkjs是否安装成功
thinkjs --version
创建项目(输入命令后一路回车知道安装成功)
thinkjs new project_name
进入项目安装npm并启动项目
cd project_name
npm install
npm start
执行完后显示下面内容表示成功
[2021-01-07T10:40:45.896] [7252] [INFO] - Server running at http://127.0.0.1:8360
[2021-01-07T10:40:45.901] [7252] [INFO] - ThinkJS version: 3.2.12
[2021-01-07T10:40:45.901] [7252] [INFO] - Environment: development
[2021-01-07T10:40:45.905] [7252] [INFO] - Workers: 1
logic deprecated logic's __after method is deprecated, it will be discarded in the next version node_modules\koa-compose\index.js:42:32
[2021-01-07T10:41:03.146] [25532] [INFO] - GET / 200 8ms
[2021-01-07T10:41:03.213] [25532] [INFO] - GET /favicon.ico 404 3ms
打开浏览器访问 http://127.0.0.1:8360/
,如果是在远程机器上创建的项目,需要把 IP 换成对应的地址。