多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 创建项目骨架 创建一个基于单模块的项目框架 ### 安装 ThinkJS 命令 ~~~sh $ npm install -g think-cli ~~~ 安装完成后,系统中会有`thinkjs`命令(可以通过`thinkjs -V`查看 think-cli 的版本号,此版本号非 thinkjs 的版本号)。如果找不到这个命令,请确认环境变量是否正确。 ### 创建项目 执行`thinkjs new [project_name]`来创建项目,如: ~~~ $ thinkjs new cms-server-thinkjs $ cd cms-server-thinkjs $ npm install $ npm start ~~~ 在询问是否打开Babel的时候选择是,开启Babel,其他的选择默认值就可以了。 ``` PS D:\在线课程\JS与WEB前端框架技术\web-js-framework-code\code\projects\cms\module-01\learning> thinkjs new cms-server-thinkjs ? Project name cms-server-thinkjs ? Project description application created by thinkjs ? Author zengqs <pypzengqs@126.com> ? Do you want to turn on babel? Yes think-cli · Generated cms-server-thinkjs To get started: # enter path $ cd cms-server-thinkjs # install dependencies: $ npm install # run the app $ npm start ``` package.json文件内容 ~~~ { "name": "cms-server-thinkjs", "description": "application created by thinkjs", "version": "1.0.0", "author": "", "scripts": { "start": "node development.js", "test": "THINK_UNIT_TEST=1 nyc ava test/ && nyc report --reporter=html", "compile": "babel --no-babelrc src/ --presets think-node --out-dir app/", "lint": "eslint src/", "lint-fix": "eslint --fix src/" }, "dependencies": { "mockjs": "^1.1.0", "think-cache": "^1.0.0", "think-cache-file": "^1.0.8", "think-logger3": "^1.0.0", "think-model": "^1.0.0", "think-model-mysql": "^1.0.0", "think-session": "^1.0.0", "think-session-file": "^1.0.5", "think-view": "^1.0.0", "think-view-nunjucks": "^1.0.1", "thinkjs": "^3.0.0" }, "devDependencies": { "babel-cli": "^6.24.1", "babel-preset-think-node": "^1.0.0", "node-notifier": "^5.0.2", "think-inspect": "0.0.2", "think-babel": "^1.0.3", "think-watcher": "^3.0.0", "eslint": "^4.2.0", "eslint-config-think": "^1.0.0", "ava": "^0.18.0", "nyc": "^7.0.0" }, "repository": "", "license": "MIT", "engines": { "node": ">=6.0.0" }, "readmeFilename": "README.md", "thinkjs": { "metadata": { "name": "cms-server-thinkjs", "description": "application created by thinkjs", "author": "", "babel": true }, "projectName": "cms-server-thinkjs", "template": "C:\\Users\\jszx\\AppData\\Roaming\\npm\\node_modules\\think-cli\\default_template", "clone": false, "isMultiModule": false } } ~~~