node后台用es6的话得用@babel/node,或者@babel/register 但是在生产环境并不适合因为
You should not be using babel-node
in production. It is unnecessarily heavy, with high memory usage due to the cache being stored in memory. You will also always experience a startup performance penalty as the entire app needs to be compiled on the fly.
Check out the example Node.js server with Babel for an idea of how to use Babel in a production deployment.
就是因为太冗余了上面两个就是实时编译太占内存空间,怎么解决官方也说了
"scripts": {
"build": "babel lib -d dist",
"start": "npm run build && nodemon dist/index.js",
"serve": "node dist/index.js"
}