5

在我的 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",

我关注了很多线程,但似乎没有任何问题可以解决我的问题。我应该怎么做才能解决这个问题?我的 package.json 中已经有 babel-core 而不是 babel,这是大多数解决方案所建议的。

4

3 回答 3

4

我通过将 gulp 版本从 3.9.1 降级到 3.9.0 解决了这个问题。看起来 3.9.1 有问题。

于 2018-02-01T19:35:25.027 回答
2

这只是 Gulp 无法加载的警告,@babel/register但在下一行它成功加载了后备模块:babel-register

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

您可以安装babel-core/register模块以删除警告,但这不是必需的。

于 2018-02-02T17:50:28.560 回答
0

npm i -D babel-register您可以使用( i= 简写install,D = 简写--save-dev)删除错误

于 2021-05-17T00:42:27.743 回答