【问题标题】:I keep getting the Error: Cannot find module 'webpack-CLI/bin/config-yargs'我不断收到错误:找不到模块'webpack-CLI/bin/config-yargs'
【发布时间】:2021-03-05 02:21:17
【问题描述】:

我正在使用this 教程制作一个 React 应用程序。我在 devDependencies 中有最新的 webpack-CLI 4.2.0。我查看了 node_modules/webpack-cli/bin/config-yargs 但它不存在。它只到“bin”,并且里面只有一个文件。它还告诉我关于

`(/Users/danielengel/Desktop/Project portfolio/watches/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)` 

    // webpack-cli@3.3 path : webpack-cli/bin/config/config-yargs
let configYargsPath;
try {
  require.resolve('webpack-cli/bin/config/config-yargs');
  configYargsPath = 'webpack-cli/bin/config/config-yargs';
} catch (e) {
  configYargsPath = 'webpack-cli/bin/config-yargs';
}
// eslint-disable-next-line import/no-extraneous-dependencies
// eslint-disable-next-line import/no-dynamic-require
require(configYargsPath)(yargs);

,并且在文件的顶部

`const yargs = require('yargs');

我试过注释掉一些代码,或者在 node_modules 中取消注释,但我知道这是个坏主意。我还尝试使用 NPM 卸载并重新安装 webpack。我尝试将其更改为常规依赖项而不是开发依赖项。我也尝试在全球范围内安装它。

【问题讨论】:

    标签: reactjs webpack


    【解决方案1】:

    尝试在 package.json 中使用 webpack serving 代替 webpack-dev-server

    【讨论】:

      猜你喜欢
      • 2020-04-23
      • 2020-06-30
      • 1970-01-01
      • 2021-03-30
      • 2018-08-31
      • 2021-04-23
      • 2017-03-15
      • 2021-02-13
      • 1970-01-01
      相关资源
      最近更新 更多