相关文章推荐

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the bug
When compiling via Webpack, a warning/error appears. Choices.js is imported within a component.

To Reproduce
For me, it's easy to reproduce, all I need to do is compile.

WARNING in ./node_modules/choices.js/public/assets/scripts/choices.js
Module Warning (from ./node_modules/eslint-loader/dist/cjs.js):
Cannot read config file: /node_modules/choices.js/public/assets/scripts/.eslintrc.js
Error: Cannot find module '../../../.eslintrc.json'
Require stack:
- /node_modules/choices.js/public/assets/scripts/.eslintrc.js
- /node_modules/eslint/lib/cli-engine/config-array-factory.js
- /node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js
- /node_modules/eslint/lib/cli-engine/cli-engine.js
- /node_modules/eslint/lib/cli-engine/index.js
- /node_modules/eslint/lib/api.js
- /node_modules/eslint-loader/dist/getOptions.js
- /node_modules/eslint-loader/dist/index.js
- /node_modules/eslint-loader/dist/cjs.js
- /node_modules/loader-runner/lib/loadLoader.js
- /node_modules/loader-runner/lib/LoaderRunner.js
- /node_modules/webpack/lib/NormalModule.js
- /node_modules/webpack/lib/NormalModuleFactory.js
- /node_modules/webpack/lib/Compiler.js
- /node_modules/webpack/lib/webpack.js
- /node_modules/webpack-cli/bin/utils/validate-options.js
- /node_modules/webpack-cli/bin/utils/convert-argv.js
- /node_modules/webpack-cli/bin/cli.js
- /node_modules/webpack/bin/webpack.js
Error: Cannot read config file: /node_modules/choices.js/public/assets/scripts/.eslintrc.js
Error: Cannot find module '../../../.eslintrc.json'
Require stack:
- /node_modules/choices.js/public/assets/scripts/.eslintrc.js
- /node_modules/eslint/lib/cli-engine/config-array-factory.js
- /node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js
- /node_modules/eslint/lib/cli-engine/cli-engine.js
- /node_modules/eslint/lib/cli-engine/index.js
- /node_modules/eslint/lib/api.js
- /node_modules/eslint-loader/dist/getOptions.js
- /node_modules/eslint-loader/dist/index.js
- /node_modules/eslint-loader/dist/cjs.js
- /node_modules/loader-runner/lib/loadLoader.js
- /node_modules/loader-runner/lib/LoaderRunner.js
- /node_modules/webpack/lib/NormalModule.js
- /node_modules/webpack/lib/NormalModuleFactory.js
- /node_modules/webpack/lib/Compiler.js
- /node_modules/webpack/lib/webpack.js
- /node_modules/webpack-cli/bin/utils/validate-options.js
- /node_modules/webpack-cli/bin/utils/convert-argv.js
- /node_modules/webpack-cli/bin/cli.js
- /node_modules/webpack/bin/webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/node_modules/choices.js/public/assets/scripts/.eslintrc.js:3:22)
    at Module._compile (/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at module.exports (/node_modules/eslint/node_modules/import-fresh/index.js:31:59)
    at loadJSConfigFile (/node_modules/eslint/lib/cli-engine/config-array-factory.js:201:16)
    at loadConfigFile (/node_modules/eslint/lib/cli-engine/config-array-factory.js:284:20)
    at ConfigArrayFactory._loadConfigDataInDirectory (/node_modules/eslint/lib/cli-engine/config-array-factory.js:517:34)
    at ConfigArrayFactory.loadInDirectory (/node_modules/eslint/lib/cli-engine/config-array-factory.js:434:18)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:328:46)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:272:18)
    at CLIEngine.isPathIgnored (/node_modules/eslint/lib/cli-engine/cli-engine.js:951:18)
    at CLIEngine.executeOnText (/node_modules/eslint/lib/cli-engine/cli-engine.js:868:38)
    at Linter.lint (/node_modules/eslint-loader/dist/Linter.js:53:26)
    at Object.loader (/node_modules/eslint-loader/dist/index.js:26:29)
 @ ./assets/js/frontend/components/selects.js 3:0-33 13:32-39
 @ ./assets/js/frontend/frontend.js

choices.js installed via npm.
Imported into the component via: import Choices from 'choices.js';

I would love it to be a mistake on my side but I can't seem to figure it out. I don't see the .json within the choices.js directory.

@rossberenson It seems that you use eslint-loader in your Webpack configuration. You should ignore node_modules:

module.exports = {
  // ...
  module: {
    rules: [
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          // eslint options (if necessary)
  // ...
 
推荐文章