Gulp 时无法加载外部模块@babel/寄存器

gstyhher  于 2022-12-16  发布在  Gulp
关注(0)|答案(3)|浏览(169)

在我的react项目中,在我的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",

我已经跟进了很多线程,但似乎没有解决我的情况。我应该怎么做来解决这个问题?我已经有babel-core而不是babel在我的package.json大多数解决方案建议。

vs3odd8k

vs3odd8k1#

我已经解决了这个问题,把gulp版本从3. 9. 1降级到3. 9. 0。看起来3. 9. 1有缺陷。

p1iqtdky

p1iqtdky2#

这只是一个警告,Gulp无法加载@babel/register,但在下一行它成功加载了回退模块:babel-register
https://github.com/gulpjs/gulp/issues/1631
您可以安装babel-core/register模块来删除警告,但这不是必需的。

jq6vz3qz

jq6vz3qz3#

可以使用npm i -D babel-registeri = install的简写,D = --save-dev的简写)删 debugging 误

相关问题