Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在ES6中使用Gulp 4-在Babel中发布_Javascript_Node.js_Ecmascript 6_Gulp_Babeljs - Fatal编程技术网

Javascript 在ES6中使用Gulp 4-在Babel中发布

Javascript 在ES6中使用Gulp 4-在Babel中发布,javascript,node.js,ecmascript-6,gulp,babeljs,Javascript,Node.js,Ecmascript 6,Gulp,Babeljs,我希望能够使用ES6语法进行全局Gulp配置 我一直在迁移到Gulp4,并找到了使用ES6语法的好机会。但是,我对所有项目都使用一次一口的配置 问题 巴别塔 当Gulp与项目位于同一文件夹中时,一切正常,但是当我将其移到项目外部时,它似乎不会将Babel配置错误解释为Babel尚未配置 $ gulp Requiring external module @babel/register /usr/local/share/build/gulp-babel/tasks/build.js:7 import

我希望能够使用ES6语法进行全局Gulp配置

我一直在迁移到Gulp4,并找到了使用ES6语法的好机会。但是,我对所有项目都使用一次一口的配置

问题

巴别塔

当Gulp与项目位于同一文件夹中时,一切正常,但是当我将其移到项目外部时,它似乎不会将Babel配置错误解释为Babel尚未配置

$ gulp
Requiring external module @babel/register
/usr/local/share/build/gulp-babel/tasks/build.js:7
import {series, parallel} from 'gulp';
       ^

SyntaxError: Unexpected token {
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:656:28)
    at Module._compile (node_modules/@babel/register/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Object.newLoader [as .js] (node_modules/@babel/register/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
文件结构

- ProjectFolder/
    build/
    public/
    My/Shared/Gulp -> Symlink
    gulpfile.js -> Gets the gulpfile.babel.js via require() or import

- /My/Shared/Gulp/
    tasks/
    node_modules/
    .babelrc
    gulpfile.babel.js -> this has been tested and works fine when in project folder
注意
ProjectFolder
中的
My/Shared/Gulp
是一个符号链接

我尝试过但没有成功的事情

  • 使用
    .babelrc
    Babel.config.js
  • 创建了一个带有Babel配置的
    package.json
    文件
  • 在本地
    gulpfile.js
    上,同时使用:
    • require('global/gulpfile.babel.js')
    • 从'/My/Shared/Gulp/tasks/build'导入{build}
  • gulpfile.js
    重命名为
    gulpfile.babel.js
    ,并将
    .babelrc
    包含在项目文件夹中
  • 创建指向全局Gulp文件的符号链接
基本上,我认为需要一个全局的
babel.config.js

任何想法都将不胜感激!提前谢谢