Tag: babel

运行node.js时出现错误与babel“无法find预设”es2015“相对于目录”

嗨,我试图用巴贝尔编译我的项目。 我试图运行时得到这个错误(我使用babel作为一些代码包含ES6) /usr/local/bin/node -r babel-register /Volumes/Elements/Learning/Node/Project/building-apis-with-nodejs-master/ntask-api/index.js /Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328 throw e; ^ Error: Couldn't find preset "es2015" relative to directory "/Volumes/Elements/Learning/Node/Project/building-apis-with-nodejs-master/ntask-api" at /Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19 at Array.map (native) at OptionManager.resolvePresets (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) at OptionManager.mergePresets (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) at OptionManager.mergeOptions (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) at OptionManager.init (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) at compile (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-register/lib/node.js:103:45) at loader (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-register/lib/node.js:144:14) at Object.require.extensions.(anonymous function) [as .js] (/Volumes/Elements/Dev/Node.js/building-apis-with-nodejs-master/ntask-api/node_modules/babel-register/lib/node.js:154:7) at Module.load (module.js:488:32) Process finished with exit […]

巴贝尔:“关键字'等待'被保留(53:24)”

我们正在使用asynchronous/等待我们的Meteor项目。 这个语法无处不在我们的resolvers.js。 一切正常,直到我们已经升级到节点6.7。 现在每次我们尝试构build它时,都会显示这个错误: “关键字'等待'被保留(53:24)” 有谁知道如何解决这个问题? 这里是我的.babelrc文件的内容: { "presets": ["es2015", "stage-2", "react"], "plugins": ["react-require", "babel-root-slash-import"] }

React Native初学者项目捆绑失败,出现意外令牌错误

我正在尝试使用https://facebook.github.io/react-native/docs/getting-started.html上的说明为Android创build我的第一个React Native应用程序。 设置依赖关系并连接我的Android设备后,我跑了 react-native init app cd app react-native run-android 这将启动React Packager,该错误与此错误捆绑失败: 错误:捆绑失败:“TransformError:/Users/luky/dev/app/index.android.js:Unexpected token)(处理预设:\”/ Users / luky / dev / app / node_modules / babel-preset-react-本地/ index.js \ “)” 我在用: OSX El Capitan 10.11.6。 节点版本6.9.2 react-native版本0.47.1。 我将生成的项目(包括node_modules)推送到Github,以防万一: https : //github.com/luky1971/react-native-app 有谁知道为什么我可能会得到一个意外的令牌错误? 任何帮助将不胜感激!

nodejs 8导入模块 – 需要还是导入?

只是想知道我们如何在node.js中导入一个模块8 – 我们还在使用require吗? 还是我们还需要使用import babel? 我一直在挖,但似乎没有答案。 如果还需要使用require,为什么node不能实现import呢?