17koa / runkoa Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED runkoa:使用koa1和koa2的时候,不用在意babel的细节,无论哪种写法(common, generator, async)都完美支持
Home Page: https://github.com/17koa/runkoa
License: MIT License
DEPRECATED runkoa:使用koa1和koa2的时候,不用在意babel的细节,无论哪种写法(common, generator, async)都完美支持
Home Page: https://github.com/17koa/runkoa
License: MIT License
D:\repositories\test\node_modules\koa-bodyparser\index.js:72
return async function bodyParser(ctx, next) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .js] (D:\repositories\test\node_modules\babel-register\lib\node.js:152:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
[nodemon] app crashed - waiting for file changes before starting...
error: runkoa entry file is not exist, please check it
看一下这个fork
https://github.com/wssgcg1213/runkoa
travis-ci
https://travis-ci.org/wssgcg1213/runkoa
使用koa-generator生成一个项目,运行时出pluginUnknown的错误,node版本6.9.1
如果使用node7,是没有问题的。
$ nvm use 6.9.1
Now using node v6.9.1 (npm v4.0.3)
$ DEBUG=HelloKoa2:* npm start pm2
> [email protected] start /HelloKoa2
> nodemon bin/run "pm2"
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node bin/run pm2`
3babel presets path = /HelloKoa2/node_modules/runkoa/node_modules
/HelloKoa2/node_modules/babel-core/lib/transformation/file/options/option-manager.js:176
throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
^
ReferenceError: Unknown plugin "/HelloKoa2/node_modules/runkoa/node_modules/babel-plugin-add-module-exports" specified in "base" at 0, attempted to resolve relative to "/HelloKoa2/bin"
at/Works/HelloKoa2/node_modules/babel-core/lib/transformation/file/options/option-manager.js:176:17
at Array.map (native)
at Function.normalisePlugins (/HelloKoa2/node_modules/babel-core/lib/transformation/file/options/option-manager.js:154:20)
at OptionManager.mergeOptions (/HelloKoa2/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:36)
at OptionManager.init (/HelloKoa2/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12)
at compile (/HelloKoa2/node_modules/babel-register/lib/node.js:103:45)
at loader (/HelloKoa2/node_modules/babel-register/lib/node.js:144:14)
at Object.require.extensions.(anonymous function) [as .js] (/HelloKoa2/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
[nodemon] app crashed - waiting for file changes before starting...
runkoa bin/www
bin/www
3babel presets path = /usr/local/lib/node_modules/runkoa/node_modules/
module.js:328
throw err;
^
Error: Cannot find module 'runkoa'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (www:3:1)
at Module._compile (module.js:398:26)
at loader (/usr/local/lib/node_modules/runkoa/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js]
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
本地的package.json 和node_modules下都没有runkoa的依赖
是否需要也在本地安装一下runkoa?
我尝试本地安装 npm install runkoa --save 后执行 runkoa bin/www 还是报错
runkoa bin/www
bin/www
3babel presets path = /Users/liutao/work/velocity_static_koa/node_modules/.npminstall/runkoa/1.5.2/runkoa/node_modules/
/Users/liutao/work/velocity_static_koa/app.js
2babel presets path = /Users/liutao/work/velocity_static_koa/node_modules/.npminstall//1.5.2/runkoa
/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-core/6.10.4/babel-core/lib/transformation/file/options/option-manager.js:204
throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
^
ReferenceError: Unknown plugin "/Users/liutao/work/velocity_static_koa/node_modules/.npminstall//1.5.2/runkoababel-plugin-add-module-exports" specified in "base" at 0, attempted to resolve relative to "/Users/liutao/work/velocity_static_koa"
at /Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-core/6.10.4/babel-core/lib/transformation/file/options/option-manager.js:204:17
at Array.map (native)
at Function.normalisePlugins (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-core/6.10.4/babel-core/lib/transformation/file/options/option-manager.js:180:20)
at OptionManager.mergeOptions (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-core/6.10.4/babel-core/lib/transformation/file/options/option-manager.js:300:36)
at OptionManager.init (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-core/6.10.4/babel-core/lib/transformation/file/options/option-manager.js:488:10)
at compile (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-register/6.9.0/babel-register/lib/node.js:112:69)
at loader (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-register/6.9.0/babel-register/lib/node.js:158:14)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/Cellar/node/5.4.0/bin/node" "/usr/local/bin/npm" "run" "start"
npm ERR! node v5.4.0
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: runkoa bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'runkoa bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the velocity_static_koa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! runkoa bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls velocity_static_koa
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/liutao/work/velocity_static_koa/npm-debug.log
runkoa app 执行提示找不下入口,runkoa bin/www 又提示babel-polyfill的实例重复
velocity_static_koa runkoa app
app
3babel presets path = /usr/local/lib/node_modules/runkoa/node_modules/
runkoa entry file is not exist, please check it
➜ velocity_static_koa runkoa bin/www
bin/www
3babel presets path = /usr/local/lib/node_modules/runkoa/node_modules/
/Users/liutao/work/velocity_static_koa/app.js
/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-polyfill/6.9.1/babel-polyfill/lib/index.js:12
throw new Error("only one instance of babel-polyfill is allowed");
^
Error: only one instance of babel-polyfill is allowed
at Object. (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/babel-polyfill/6.9.1/babel-polyfill/lib/index.js:12:9)
at Module._compile (module.js:398:26)
at Module._extensions..js (module.js:405:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/Users/liutao/work/velocity_static_koa/node_modules/.npminstall/runkoa/1.5.2/runkoa/index.js:3:1)
at Module._compile (module.js:398:26)
您好!很感谢您开发了runkoa,可以让我们这些新手很方便的使用koa2+async组合,但是在使用的过程中,出现一个问题,我是初学koa,在bin/www中使用 require('runkoa')(__dirname + '/app.js' )调用app.js的时候,发现每次都不会执行app.js,最后发现在index.js代码中有这么一句:
var f = current_path + '/bin/www'
if (is_cli == true && entry && /^\//.test(entry)){
f = entry
}
也就是说如果不是直接在命令行执行,那么f的指向的文件都会是bin/www,所以每次都无法执行app.js。
不知道这是您专门这么写的,还是一个失误呢?
我也是初学node,如有不当之处 还望指正! 谢谢
因为babel用了些时间来转化代码,然后browserSync在babel转化没完成之前就启动了,导致端口冲突
主要是为了rest和spread写法,让代码更简洁
My breakpoints can't work....
Help...
如果node版本是6.2.0,是不是直接使用koa2+async,不需要babel或者runkoa了呢?
➜ koa-demo runkoa index.js
index.js
/Users/sang/workspace/17koa/koa-demo/node_modules/babel-polyfill/lib/index.js:14
throw new Error("only one instance of babel-polyfill is allowed");
^
Error: only one instance of babel-polyfill is allowed
at Object.<anonymous> (/Users/sang/workspace/17koa/koa-demo/node_modules/babel-polyfill/lib/index.js:14:9)
at Module._compile (module.js:434:26)
at Module._extensions..js (module.js:452:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/sang/workspace/github/runkoa/node_modules/babel-register/lib/node.js:134:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (index.js:3:1)
at Module._compile (module.js:434:26)
➜ koa-demo cat index.js
'use strict';
require("babel-polyfill");
// set babel in entry file
require('babel-core/register')({
presets: ['es2015-node5', 'stage-3']
});
require('./app'); // this is es7 - gets transpiled
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.