node.js - gulp 无法识别导入关键字,抛出 SyntaxError : Unexpected reserved word

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

最佳答案

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

<小时/>

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

关于node.js - gulp 无法识别导入关键字,抛出 SyntaxError : Unexpected reserved word,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34249672/

相关文章:

node.js - 无法在生产服务器中的 Docker 容器上模块 'reflect-metadata'

javascript - HtmlWebpackPlugin 不包含 vendor.js

google-app-engine - 在 AppEngine 上设置 SSL...分配的 URL "empty"

google-app-engine - 在 Google App Engine 中,记录已放入内存缓存的项目的最简单方法是什么?

python - Tweepy Google App Engine 计费错误

javascript - NPM在nodejs中获取中止错误

node.js - 为什么 Debian/Ubuntu 上只能使用过时的 NPM 版本?

javascript - REST api/postman - 无法获取/路由错误

node.js - 有没有一种方法可以使用 Node/Express 2.x 检查已发送的 header ?

c++ - 错误 MSB8007 : The Platform for project XXX is invalid. 平台 ='x64'