Field 'browser' doesn't contain a valid alias configuration

后端 未结 16 2261
无人共我
无人共我 2020-12-01 11:54

I\'ve started using webpack2 (to be precise, v2.3.2) and after re-creating my config I keep running into an issue I can\'t seem to solve I get (sorry in advance

相关标签:
16条回答
  • 2020-12-01 12:02

    I had the same issue, but mine was because of wrong casing in path:

    // Wrong - uppercase C in /pathCoordinate/
    ./path/pathCoordinate/pathCoordinateForm.component
    
    // Correct - lowercase c in /pathcoordinate/
    ./path/pathcoordinate/pathCoordinateForm.component
    
    0 讨论(0)
  • 2020-12-01 12:04

    I'm building a React server-side renderer and found this can also occur when building a separate server config from scratch. If you're seeing this error, try the following:

    1. Make sure your "entry" value is properly pathed relative to your "context" value. Mine was missing the preceeding "./" before the entry file name.
    2. Make sure you have your "resolve" value included. Your imports on anything in node_modules will default to looking in your "context" folder, otherwise.

    Example:

    const serverConfig = {
    name: 'server',
    context: path.join(__dirname, 'src'),
    entry: {serverEntry: ['./server-entry.js']},
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'server.js',
        publicPath: 'public/',
        libraryTarget: 'commonjs2'
    },
    module: {
        rules: [/*...*/]
    },
    resolveLoader: {
        modules: [
            path.join(__dirname, 'node_modules')
        ]
    },
    resolve: {
        modules: [
            path.join(__dirname, 'node_modules')
        ]
    }
    };
    
    0 讨论(0)
  • 2020-12-01 12:07

    In my case it was a package that was installed as a dependency in package.json with a relative path like this:

    "dependencies": {
      ...
      "phoenix_html": "file:../deps/phoenix_html"
    },
    

    and imported in js/app.js with import "phoenix_html"

    This had worked but after an update of node, npm, etc... it failed with the above error-message.

    Changing the import line to import "../../deps/phoenix_html" fixed it.

    0 讨论(0)
  • 2020-12-01 12:07

    In my case, to the very end of the webpack.config.js, where I should exports the config, there was a typo: export(should be exports), which led to failure with loading webpack.config.js at all.

    const path = require('path');
    
    const config = {
        mode: 'development',
        entry: "./lib/components/Index.js",
        output: {
            path: path.resolve(__dirname, 'public'),
            filename: 'bundle.js'
        },
        module: {
            rules: [
                {
                    test: /\.js$/,
                    loader: 'babel-loader',
                    exclude: path.resolve(__dirname, "node_modules")
                }
            ]
        }
    }
    
    // pay attention to "export!s!" here
    module.exports = config;
    
    0 讨论(0)
  • 2020-12-01 12:07

    In my experience, this error was as a result of improper naming of aliases in Webpack. In that I had an alias named redux and webpack tried looking for the redux that comes with the redux package in my alias path.

    To fix this, I had to rename the alias to something different like Redux.

    0 讨论(0)
  • 2020-12-01 12:07

    For everyone with Ionic: Updating to the latest @ionic/app-scripts version gave a better error message.

    npm install @ionic/app-scripts@latest --save-dev
    

    It was a wrong path for styleUrls in a component to a non-existing file. Strangely it gave no error in development.

    0 讨论(0)
提交回复
热议问题