简体   繁体   中英

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received '' error

While I am try to build react app then it show this error

node:internal/errors:465 ErrorCaptureStackTrace(err); ^

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received '' at new NodeError (node:internal/errors:372:5) at Module.require (node:internal/modules/cjs/loader:1000:11) at require (node:internal/modules/cjs/helpers:102:18) at getConfigAsObject (C:\Users\syam.das\Desktop\5\doe-web\node_modules@craco\craco\lib\config.js:46:20) at loadCracoConfigAsync (C:\Users\syam.das\Desktop\5\doe-web\node_modules@craco\craco\lib\config.js:69:34) at Object. (C:\Users\syam.das\Desktop\5\doe-web\node_modules@craco\craco\scripts\start.js:22:1) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) { code: 'ERR_INVALID_ARG_VALUE' } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

        const path = require("path");
    const fs = require("fs");
    const { getArgs } = require("./args");
    const { log } = require("./logger");
    const { isString } = require("./utils");

    const projectRoot = fs.realpathSync(process.cwd());
    const packageJsonPath = path.join(projectRoot, "package.json");

    log("Project root path resolved to: ", projectRoot);

    let configFilePath = "";

    const configFilenames = ["craco.config.js", ".cracorc.js", ".cracorc"];

    const args = getArgs();

    if (args.config.isProvided) {
        configFilePath = path.resolve(projectRoot, args.config.value);
    } else {
        const package = require(packageJsonPath);

        if (package.cracoConfig) {
            if (!isString(package.cracoConfig)) {
                throw new Error("craco: 'cracoConfig' value must be a string.");
            }

            configFilePath = path.resolve(projectRoot, package.cracoConfig);
        } else {
            for (const filename of configFilenames) {
                const filePath = path.join(projectRoot, filename);

                if (fs.existsSync(filePath)) {
                    configFilePath = filePath;
                    break;
                }
            }
        }
    }

    log("Config file path resolved to: ", configFilePath);

    module.exports = {
        projectRoot,
        packageJsonPath,
        configFilePath
    };

I just type yarn add @craco/craco in console and now its working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM