Failed to load external module babel-core/register
Failed to load external module babel/register
somelocation\gulpfile.babel.js:27
import fs from 'fs';
^^^^^^

SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:452:10)
    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 Liftoff.handleArguments (\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:116:3)
    at Liftoff.<anonymous> (\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:192:16)
    at module.exports (\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\node_modules\flagged-respawn\index.js:17:3)


我尝试在npm之后运行gulp时遇到此错误,如下所述:deploy-appengine.md。如何解决?

最佳答案

编辑:正如卢克·本内特(Luke Bennet)在对此答案的评论中正确指出的那样,它的确是JavaScript-ES6 "import" syntax。问题在于,这还不能在Node中立即使用。



您似乎在NodeJS中使用python module import syntax。您应该使用NodeJS module require syntax

关于node.js - gulp throw 语法错误无法识别导入关键字:意外的保留字,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34249672/

10-09 20:36