【问题标题】:node module installation causing error when mixing混合时节点模块安装导致错误
【发布时间】:2019-09-01 06:04:56
【问题描述】:

我有一个在 laravel 上运行的服务器,我想在其中添加一个名为“nodemailer”的节点模块。但是每当我在后台运行npm run watch 或运行npm run dev 时,如果我安装“nodemailer”就会显示错误。 错误:

ERROR in ./node_modules/@babel/runtime/regenerator/index.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/@babel/runtime/regenerator/index.js'
 @ ./resources/js/index.js 1:0-61 24:4-23 26:13-32 100:4-23 102:13-32 160:4-23 161:13-32 186:4-23 187:13-32 216:4-23 218:13-32 257:4-23 260:13-32 306:4-23 309:13-32 355:4-23 358:13-32 399:4-23 402:13-32 442:4-23 445:13-32 493:4-23 496:13-32 535:4-23 538:13-32 580:4-23 582:13-32 618:4-23 620:13-32 657:4-23 659:13-32
 @ multi ./resources/js/index.js

ERROR in ./node_modules/process/browser.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/process/browser.js'
 @ ./node_modules/axios/lib/defaults.js 1:0-37
 @ ./node_modules/axios/lib/axios.js
 @ ./node_modules/axios/index.js
 @ ./resources/js/bootstrap.js
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js

ERROR in ./node_modules/timers-browserify/main.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/timers-browserify/main.js'
 @ ./node_modules/vue/dist/vue.common.dev.js 1:0-44
 @ ./node_modules/vue/dist/vue.common.js
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js

ERROR in ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/vue-loader/lib/runtime/componentNormalizer.js'
 @ ./resources/js/components/ExampleComponent.vue 7:0-93 8:16-26
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js

ERROR in ./node_modules/web3/dist/web3.umd.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/web3/dist/web3.umd.js'
 @ ./resources/js/index.js 7:0-43 700:19-23 705:19-23 705:28-32
 @ multi ./resources/js/index.js

ERROR in (webpack)/buildin/global.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/webpack/buildin/global.js'
 @ ./node_modules/lodash/lodash.js 1:0-41
 @ ./resources/js/bootstrap.js
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js

ERROR in (webpack)/buildin/module.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/****/projects/githubs/####/node_modules/webpack/buildin/module.js'
 @ ./node_modules/lodash/lodash.js 1:0-41
 @ ./resources/js/bootstrap.js
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js

我已经尝试使用 yarn 安装,它说节点引擎需要一个旧版本,但是当我为这个模块打开一个空文件时它可以工作

【问题讨论】:

  • 尝试 npm install 或将节点降级到旧版本,然后再次 npm install。

标签: node.js laravel webpack


【解决方案1】:

执行以下步骤:

  • 停止监视脚本(如果它正在运行)。
  • 运行 rm -rf node_modules package-lock.json 以删除任何旧的、可能已损坏的依赖项。
  • 运行npm install,从头开始干净地安装所有内容。
  • 再次运行您的代码。

假设您需要的所有依赖项都注册在package.json 文件中(并且您的代码是正确的),现在应该可以工作了。

【讨论】:

  • 但我不确定是否所有依赖项都在 package.json 文件中。有没有办法列出 package.json 文件中的所有模块?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-31
  • 1970-01-01
  • 2018-08-16
  • 2016-11-12
  • 2019-11-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多