17koa / koa2-demo Goto Github PK
View Code? Open in Web Editor NEWexpress风格的最新的Koa 2项目的示例,已集成到koa-generator里(执行koa2命令生成即可)
Home Page: https://github.com/17koa/koa2-demo
License: MIT License
express风格的最新的Koa 2项目的示例,已集成到koa-generator里(执行koa2命令生成即可)
Home Page: https://github.com/17koa/koa2-demo
License: MIT License
node4.3.0 npm 3.7.3 下unkoa下面的node_modules目录里没有es2015-node这个文件
安装了xtemplate,改了报错
app.use(views(__dirname + '/views-xtemplate', {
extension: 'xtpl'
}));
// app.use(views(__dirname + '/views-ejs', {
// extension: 'ejs'
// }));
您好,怎么获取params的值,post请求也无法获取request.body,求答疑。
http://127.0.0.1:3000/users?name=tom
请问 怎么使用mongoose 怎么使用model
支不支持热更新啊
LOG:
~ Sites 15:06:12 git clone https://github.com/17koa/koa2-demo.git [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
Cloning into 'koa2-demo'...
remote: Counting objects: 91, done.
remote: Total 91 (delta 0), reused 0 (delta 0), pack-reused 91
Unpacking objects: 100% (91/91), done.
Checking connectivity... done.
~ Sites 15:06:21 cd koa2-demo [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
~ Sites koa2-demo master 15:06:25 cnpm i [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
[co@^4.6.0] installed at node_modules/.npminstall/co/4.6.0/co (0 packages, use 675ms, speed 67.66kB/s, json 46.28kB, tarball 0B)
[[email protected]] deprecate: Jade has been renamed to pug, please install the latest version of pug instead of jade
[debug@^2.2.0] installed at node_modules/.npminstall/debug/2.2.0/debug (0 packages, use 1s, speed 132.65kB/s, json 136.36kB, tarball 0B)
[koa-convert@^1.2.0] installed at node_modules/.npminstall/koa-convert/1.2.0/koa-convert (0 packages, use 1s, speed 137.38kB/s, json 150.7kB, tarball 0B)
[koa-router@^7.0.0] installed at node_modules/.npminstall/koa-router/7.0.1/koa-router (0 packages, use 2s, speed 217.25kB/s, json 351.29kB, tarball 0B)
[koa-json@^1.1.1] installed at node_modules/.npminstall/koa-json/1.1.3/koa-json (0 packages, use 2s, speed 213.94kB/s, json 351.29kB, tarball 0B)
[koa-static@^1.5.2] installed at node_modules/.npminstall/koa-static/1.5.2/koa-static (0 packages, use 2s, speed 291.01kB/s, json 851.21kB, tarball 0B)
[koa-logger@^1.3.0] installed at node_modules/.npminstall/koa-logger/1.3.0/koa-logger (0 packages, use 3s, speed 289.02kB/s, json 976.29kB, tarball 0B)
[koa-views@^5.0.1] installed at node_modules/.npminstall/koa-views/5.0.1/koa-views (0 packages, use 2s, speed 287.23kB/s, json 979.17kB, tarball 0B)
[koa-bodyparser@^2.0.1] installed at node_modules/.npminstall/koa-bodyparser/2.0.1/koa-bodyparser (0 packages, use 4s, speed 284.07kB/s, json 1.12MB, tarball 0B)
[[email protected]] deprecate: Jade has been renamed to pug, please install the latest version of pug instead of jade
[[email protected]] deprecate: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
[should@^8.3.0] installed at node_modules/.npminstall/should/8.3.1/should (0 packages, use 3s, speed 312.93kB/s, json 1.72MB, tarball 0B)
[koa-onerror@^1.2.1] installed at node_modules/.npminstall/koa-onerror/1.3.1/koa-onerror (0 packages, use 6s, speed 311.54kB/s, json 1.83MB, tarball 0B)
[mocha@^2.4.5] installed at node_modules/.npminstall/mocha/2.4.5/mocha (0 packages, use 5s, speed 315.93kB/s, json 2.02MB, tarball 0B)
[jade@~1.11.0] installed at node_modules/.npminstall/jade/1.11.0/jade (0 packages, use 7s, speed 316.51kB/s, json 2.11MB, tarball 0B)
[supertest@^1.2.0] installed at node_modules/.npminstall/supertest/1.2.0/supertest (0 packages, use 5s, speed 289.24kB/s, json 2.28MB, tarball 0B)
[runkoa@^1.5.1] installed at node_modules/.npminstall/runkoa/1.5.2/runkoa (0 packages, use 8s, speed 260.07kB/s, json 2.28MB, tarball 0B)
[[email protected]] download from binary mirror: {"module_name":"fse","module_path":"./lib/binding/{configuration}/{node_abi}-{platform}-{arch}/","remote_path":"./v{version}/","package_name":"{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz","host":"https://npm.taobao.org/mirrors/fsevents"}
[nodemon@^1.9.1] installed at node_modules/.npminstall/nodemon/1.9.2/nodemon (0 packages, use 8s, speed 248.39kB/s, json 2.32MB, tarball 0B)
[koa@^2.0.0] installed at node_modules/.npminstall/koa/2.0.0/koa (0 packages, use 11s, speed 227.8kB/s, json 2.42MB, tarball 11.45kB)
excute post install scripts...
[[email protected]] scripts.install: "node-pre-gyp install --fallback-to-build" at /Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/fsevents/1.0.12/fsevents
node-pre-gyp http GET https://npm.taobao.org/mirrors/fsevents/v1.0.12/fse-v1.0.12-node-v46-darwin-x64.tar.gz
node-pre-gyp http 200 https://npm.taobao.org/mirrors/fsevents/v1.0.12/fse-v1.0.12-node-v46-darwin-x64.tar.gz
[fsevents] Success: "/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/fsevents/1.0.12/fsevents/lib/binding/Release/node-v46-darwin-x64/fse.node" is installed via remote
[[email protected]] scripts.install success, use 2s
All packages installed (353 packages installed from npm registry, use 13s, speed 194.54kB/s, json 442(2.42MB), tarball 11.45kB)
~ Sites koa2-demo master 15:06:45 npm start [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
> [email protected] start /Users/Liuchenling/Sites/koa2-demo
> nodemon bin/run
[nodemon] 1.9.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node bin/run`
2babel presets path = /Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall//1.5.2/runkoa
/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:220
throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
^
ReferenceError: Unknown plugin "/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall//1.5.2/runkoababel-plugin-add-module-exports" specified in "base" at 0, attempted to resolve relative to "/Users/Liuchenling/Sites/koa2-demo/bin"
at /Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:220:17
at Array.map (native)
at Function.normalisePlugins (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:196:20)
at OptionManager.mergeOptions (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:317:36)
at OptionManager.init (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:506:10)
at compile (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-register/6.8.0/babel-register/lib/node.js:112:69)
at loader (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-register/6.8.0/babel-register/lib/node.js:158:14)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-register/6.8.0/babel-register/lib/node.js:168:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
[nodemon] app crashed - waiting for file changes before starting...
我修改 node_modules/runkoa/index.js 里这部分成这样就可以了
require('babel-core/register')({
plugins: [require('babel-plugin-add-module-exports'), require('babel-plugin-transform-es2015-modules-commonjs')],
presets: [require('babel-preset-es2015-node5'), require('babel-preset-stage-3')],
babelrc: false
})
cnpm 用的 npminstall 的目录结构是软链的, 所以直接用__dirname 来拼接dir路径是会报错的, 我觉得可以直接用require('xxx')这种写法是babel 文档中支持的, 另一种是利用path.join(), 后者我没试过 可以试试
$ npm install
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v4.4.0
npm ERR! npm v3.5.0
npm ERR! code E404
npm ERR! 404 no such package available : @f/defaults
npm ERR! 404
npm ERR! 404 '@f/defaults' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'koa-views'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.