gulp throw无法识别导入关键字SyntaxError:意外的保留字

时间:2015-12-13 09:29:35

标签: node.js google-app-engine npm gulp

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。如何解决?

1 个答案:

答案 0 :(得分:1)

编辑:正如Luke Bennet在对这个答案的评论中指出的那样,确实是JavaScript - ES6 "import" syntax。问题是,这还没有在Node中开箱即用。

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