0

CO のバージョン 4.0 と Node の 0.11.14 バージョンがインストールされています。3.1 で動作する非常に単純なコード (以前のバージョンの co が異なることに気付きました)

"use strict"
const co = require('co')

const main = function*() {
    console.log('THIS IS LOGGED')
}

co(main)()

この出力が得られます:

/home/tbrown/.nvm/current/bin/node --debug-brk=23342 --nolazy
--harmony routes-to-apache-reverse-proxy.js Debugger listening on port 23342 THIS IS LOGGED /home/Documents/projects/server/routes/routes-to-apache-reverse-proxy.js:8 co(main)()
        ^ TypeError: object is not a function
    at Object.<anonymous> (/home/Documents/projects/server/routes/routes-to-apache-reverse-proxy.js:8:9)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.runMain [as _onTimeout] (module.js:501:10)
    at Timer.listOnTimeout (timers.js:133:15)

Process finished 

with exit code 1

参照している行は

co(main)()
4

1 に答える 1

2

OK CO が 3 から 4 に変更されました - これは同等のようです

"use strict"
const co = require('co')

const main = function*() {
    console.log('THIS IS LOGGED')
}

co(main).
    catch(function(e){
        console.error(e)
    })
于 2014-11-26T19:00:28.110 に答える