简体   繁体   English

React 应用程序的编译错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js)

[英]Compile error for a React app: Module build failed (from ./node_modules/babel-loader/lib/index.js)

I am trying to compile a React app.我正在尝试编译一个 React 应用程序。 I pulled the repo from Github, did yarn install and then compiled it.我从 Github 中提取了 repo, yarn install ,然后编译了它。 It gives the following error:它给出了以下错误:

Module build failed (from ./node_modules/babel-loader/lib/index.js)
SyntaxError: {file_path_here}: Unexpected character ' ​'

The the error is in the following file at function renderItem错误位于 function renderItem的以下文件中

export type DisplayItemT = {
    mainText: string;
    secondaryText: string[];
};


function renderItemsAsCards(items, options): string {
    let cardsrows_mso = '';
    for (let i = 0; i < items.length; ) {
        let cards = '';
        const record = items[i];
        const item={mainText: record.get('name'),secondaryText: [record.get('department'), record.get('location')]};
        const card = renderItem(item);

        cards = cards.concat(card);
        i++;
        if( i === items.length) {
            break;
        }

        cardsrows_mso = cards ? cardsrows_mso.concat(cards): ``;
        
    }

    return cardsrows_mso ? `
    <table width="100%" border="0" style="text-align: ${options.align || 'left'};">
        <tbody>
            <tr>
                ${cardsrows_mso}
            </tr>
        </tbody>
    </table>
    `
    :``;
}

function renderItem(item​​​​​​​: DisplayItemT): string {
    return `<td style="height: 100%; padding: 5px; width: 202px; max-width: 320px; min-width: 202px; display: inline-block;">
                <div style="width: 100%; padding: 15px 0px 20px; text-align: center; border: 1px solid #cccccc; border-radius: 5px; height: 100%">
                    <h6 style="font-size: 15px; font-weight: 500; color: #333; line-height: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0;">${item.mainText}</h6>
                    <p style="font-size: 13px; line-height: 17px; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${item.secondaryText[0]}</p>
                    <p style="font-size: 13px; line-height: 17px; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${item.secondaryText[1]}</p>
                </div>
            </td>`;
}

I get the above mention error, and the location of error is in the line function renderItem(item: DisplayItemT): string { at the end of parameter item in the above line.我收到上面提到的错误,错误的位置在function renderItem(item: DisplayItemT): string {在上一行参数item的末尾。 It says there's an unexpected character ' ' but I can't find any extra blank spaces anywhere.它说有一个意外的字符' '但我在任何地方都找不到任何额外的空格。

Also the function renderItem is separated because it needs to be used in other files. function renderItem也被分开,因为它需要在其他文件中使用。 But if I put the string code from that function inside renderItemsAsCards (which calls 'renderItem') the code compiles fine.但是,如果我将 function 中的字符串代码放入renderItemsAsCards (调用“renderItem”)中,则代码编译得很好。

My package.json, webpack.config.js files are pretty huge.我的 package.json、webpack.config.js 文件非常庞大。 So if I should post something from them please let me know.所以如果我应该从他们那里发布一些东西,请告诉我。 I would appreciate any help with this我将不胜感激

Most of the time I've faced This Issue is because I've added/removed a package or component, Firstly you should try and install the package separately, coz' sometimes the package is not installed by using yarn/npm install.大多数时候我遇到这个问题是因为我已经添加/删除了 package 或组件,首先你应该尝试单独安装 package,因为有时 ZEFE90A8E604A7C840D7 install.ZEFE90A8E604A7C840E88D03 没有安装。 And this might get fixed by restarting the server/APP or alternatively, you can also try to change the browser tab or restart the browser.这可以通过重新启动服务器/应用程序来解决,或者您也可以尝试更改浏览器选项卡或重新启动浏览器。 If not then kindly share the last file you've made change in the error is mostly due to the change in some component如果不是,请分享您所做的最后一个文件更改错误主要是由于某些组件的更改

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):语法错误: - Error: Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: 未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js) - Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js) 反应构建错误:模块构建失败(来自 ./node_modules/babel-loader/lib/index.js): - React build error: Module build failed (from ./node_modules/babel-loader/lib/index.js): 错误 in./src/index.js 模块构建失败(来自./node_modules/babel-loader/lib/index.js): - ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js)Vue Js - Module build failed (from ./node_modules/babel-loader/lib/index.js) Vue Js 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js) - Module build failed (from ./node_modules/babel-loader/lib/index.js) 模块构建失败(来自./node_modules/babel-loader/lib/index.js): - Module build failed (from ./node_modules/babel-loader/lib/index.js): 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):错误:找不到模块“./src/data” - Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module './src/data' 错误 in./src/app.js 模块构建失败(来自./node_modules/babel-loader/lib/index.js):错误:找不到模块'@babel/preset-present-env' - ERROR in ./src/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module '@babel/preset-present-env' 如何解决未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js): - How to Solve Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM