Giter Site home page Giter Site logo

17koa / runkoa Goto Github PK

View Code? Open in Web Editor NEW
100.0 8.0 15.0 33 KB

DEPRECATED runkoa:使用koa1和koa2的时候,不用在意babel的细节,无论哪种写法(common, generator, async)都完美支持

Home Page: https://github.com/17koa/runkoa

License: MIT License

JavaScript 100.00%

runkoa's Issues

不能处理node_module中含有的async语法,比如[email protected]

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...

pluginUnknown错误

使用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模块

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的实例重复

难道是这个插件不能和现有的koa项目使用吗?我的koa 是1.2.0的版本

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)

在代码里面使用 require('runkoa')(__dirname + '/app.js' ) 有时会有错误!

您好!很感谢您开发了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,如有不当之处 还望指正! 谢谢

重复引用require("babel-polyfill")可能出现的问题

➜  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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.