web-dev-qa-db-ja.com

gulp中に外部モジュール@ babel / registerをロードできませんでした

私の反応プロジェクトでは、すべてのvmwareで正常に動作します。しかし、同じアプリを複製してgulpコマンドを実行すると、コンパイル中に次のエラーが表示されます。

   MacBook-Pro:Frontend1.0 apurvgandhwani$ gulp
[18:42:31] Failed to load external module @babel/register
[18:42:31] Requiring external module babel-register
[18:42:32] Using gulpfile ~/Frontend1.0/gulpfile.babel.js
[18:42:32] Starting 'build:watch'...
[18:42:32] Starting 'copy:assets'...
[18:42:32] Starting 'copy:vendors'...
  Cleaned build/ 
  Copied 12 asset entries.
[18:42:32] Finished 'copy:vendors' after 329 ms
[18:42:32] Starting 'copy:views'...
[18:42:32] copied views all files 19.75 kB
[18:42:32] Finished 'copy:views' after 77 ms
[18:42:32] Starting 'copy:public'...
[18:42:33] Finished 'copy:public' after 132 ms
[18:42:33] Finished 'copy:assets' after 540 ms
[18:42:33] Starting 'bundle:dll'...
DLL Bundled.
Hash: 45f26d608c690be6e6c5
Version: webpack 1.15.0
Time: 2181ms
        Asset     Size  Chunks             Chunk Names
dll.vendor.js  3.11 MB       0  [emitted]  vendor
[18:42:35] Finished 'bundle:dll' after 2.21 s
[18:42:35] Starting 'bundle'...
Hash: 7457a3cd38cf5c991640
Version: webpack 1.15.0
Time: 508ms
           Asset     Size  Chunks             Chunk Names
server-bundle.js  37.3 kB       0  [emitted]  main
  -- server:watch bundled.
Hash: e4a95c52aac91b47f75c
Version: webpack 1.15.0
Time: 46339ms
         Asset     Size  Chunks             Chunk Names
main-bundle.js  20.1 MB       0  [emitted]  main
  -- client bundled.
[18:43:21] Finished 'bundle' after 46 s
[18:43:21] Starting 'start:server'...
Starting Node Server...
[18:43:21] Finished 'start:server' after 68 ms
[18:43:21] Starting 'watch:sync'...
[18:43:21] [nodemon] 1.11.0
[18:43:21] [nodemon] to restart at any time, enter `rs`
[18:43:21] [nodemon] watching: build/server-bundle.js
[18:43:21] [nodemon] starting `node --debug build/server-bundle.js`
Server Restarted: Reloading BrowserSync.
(node:6700) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
[18:43:21] [nodemon] app crashed - waiting for file changes before starting...
[tessact: ] Proxying: http://localhost:4200
[tessact: ] Access URLs:
 -------------------------------------
       Local: http://localhost:3001
    External: http://192.168.0.32:3001
 -------------------------------------
          UI: http://localhost:3002
 UI External: http://192.168.0.32:3002
 -------------------------------------
[tessact: ] Watching files...
[18:43:21] Finished 'watch:sync' after 262 ms
[18:43:21] Starting 'watch:assets'...
[18:43:22] Finished 'watch:assets' after 110 ms
[18:43:22] Finished 'build:watch' after 50 s
[18:43:22] Starting 'default'...
[18:43:22] Finished 'default' after 37 μs
webpack built e4a95c52aac91b47f75c in 26323ms
Hash: e4a95c52aac91b47f75c
Version: webpack 1.15.0
Time: 26323ms
         Asset     Size  Chunks       Chunk Names
main-bundle.js  20.1 MB       0       main
webpack: Compiled successfully.
[18:50:28] [nodemon] restarting due to changes...
[18:50:28] [nodemon] starting `node --debug build/server-bundle.js`
Server Restarted: Reloading BrowserSync.
[tessact: ] Reloading Browsers...
(node:6705) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
[18:50:28] [nodemon] app crashed - waiting for file changes before starting...
Abort trap: 6

これは私のpackage.jsonスニペットです

 "dependencies": {
    "@trendmicro/react-toggle-switch": "^0.5.5",
    "animate.css": "^3.5.1",
    "axis": "^0.6.1",
    "babel-core": "^6.10.4",
    "babel-loader": "^6.2.4",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.1",
    "babel-preset-react-hmre": "^1.1.1",

私は多くのスレッドをフォローしましたが、私のケースを解決するようには思えません。これを解決するにはどうすればよいですか?ほとんどのソリューションが示唆しているように、package.jsonにはbabelではなくbabel-coreがすでにあります。

5
EdG

Gulpのバージョンを3.9.1から3.9.0にダウングレードすることで解決しました。 3.9.1はバグがあるようです。

3
ApurvG

これはGulpが@babel/registerの読み込みに失敗したという警告にすぎませんが、次の行でフォールバックモジュールを正常に読み込みました:babel-register

https://github.com/gulpjs/gulp/issues/1631

babel-core/registerモジュールをインストールして警告を削除することもできますが、必須ではありません。

1
Toma Nistor