Closed raminious closed 5 years ago
i meet same error, how can solve it??
@uerbin I think it's babel issue, but I don't know how should I deal with that because I need babel-cli to run my app
@raminious did you use the babel version koa-session2@babel
?
@raminious i use babel-register ^6.24.0
.babelrc { "presets": ["latest"], "plugins": ["transform-object-rest-spread", "transform-class-constructor-call"] }
at first , plugins is ["transform-object-rest-spread"], "transform-class-constructor-call" is added later, but not work
"devDependencies": { "babel-loader": "^6.4.0", "babel-plugin-transform-class-constructor-call": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-preset-latest": "^6.24.0", "babel-register": "^6.24.0", "css-loader": "^0.27.3", "extract-text-webpack-plugin": "^2.1.0", "file-loader": "^0.10.1", "koa-webpack": "^0.3.1", "node-sass": "^4.5.0", "nodemon": "^1.11.0", "sass-loader": "^6.0.3", "style-loader": "^0.13.2", "url-loader": "^0.5.8", "webpack": "^2.2.1" }
maybe i know it
because the module write in new syntax, and not compile it to es5 version and publish it, so when use it online, it can't run, must with babel-register.
use the option can solve it, but cause new problem.
require('babel-register')({
ignore: false
});
@uerbin you can run npm install --save koa-session2@babel
to use the babel version.
Here is the doc.
Thanks @Secbone @uerbin I will close this issue
@raminious thanks.
@Secbone hello, did you merge the latest commits to babel branch?
@ilaipi Koa2 is required node 7.6.0+, so it doesn't need babel anymore.
@Secbone my node is 8.14.0 still not work.
@ilaipi did you use the master version? could you show me some details?
@Secbone maybe it's because I use babel-node, because I need import
&export
, so I think the babel branch is still needed?
@ilaipi no, you can use the latest version directly, and use import
export
with babel.
@Secbone my babel plugin don't compile node_modules dir only my src dir.
@ilaipi yes, just use it. It's compatible. 😄
@Secbone have u ever tried this? I just upgraded my babel-node to 7.x, but it still don't work.
// babel-node src/app.js
TypeError: Class constructor Store cannot be invoked without 'new'
"koa-session2": "^2.2.8",
(rm node_modules and re-install)
@ilaipi could you try to disable 'babel-plugin-transform-classes
to run it?
like this:
presets: [
["env", { exclude: ["babel-plugin-transform-es2015-classes"] }]
]
And I think maybe you don't need babel-node
anymore, you can use the latest version of node
(11.4 now). Come on, it's almost 2019 now!
@Secbone do u use import
& export
? if don't use babel-node
, how to use them?
@babel/plugin-transform-es2015-classes became @babel/plugin-transform-classes.
// but not work.
The plugins/built-ins '@babel/plugin-transform-classes' passed to the 'exclude' option are not
// the same as babel-plugin-transform-es2015-classes
@ilaipi Okay, I will test it later, maybe tonight I will publish a new version of babel
branch. 😄
@Secbone thank you!
@ilaipi Okay, I will test it later, maybe tonight I will publish a new version of
babel
branch. 😄
@Secbone Hello, I have switch my session manager lib to koa-session-minimal and koa-redis. It seems koa-session2
don't compatible with koa-passport
.
I got this error when try to use your package:
Store.js
app: