NodeJS TypeError [ERR_INVALID_ARG_VALUE]:参数“id”必须是非空字符串,收到“”错误

wljmcqd8  于 2023-04-05  发布在  Node.js
关注(0)|答案(2)|浏览(486)

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
    };
ni65a41a

ni65a41a1#

我只是在控制台中输入yarn add @craco/craco,现在它工作正常。

z9ju0rcb

z9ju0rcb2#

你是项目中的用户require(“”),但你缺少require函数的参数,因此收到以下错误“TypeError [ERR_INVALID_ARG_VALUE]:参数“id”必须是非空字符串。接收到“”;
在你的代码中,你是空的,require函数像这样const userProfile=require(“”)它的worng:user like this:const profileSchema=require(“../../models/profile/profileSchema”)

相关问题