gpt4 book ai didi

Failed to compile. webpack is not a function(编译失败。Webpack不是一个函数)

翻译 作者:bug小助手 更新时间:2023-10-26 22:14:15 25 4
gpt4 key购买 nike



My project was working fine but after installing react-redux and redux i can't start the project it shows me this error

我的项目工作得很好,但在安装了Reaction-Redux和Redux之后,我无法启动项目,它显示了这个错误



Failed to compile.

编译失败。



webpack is not a function

webpack不是函数



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.


npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

NPM错误!这可能不是NPM的问题。上面可能还有额外的日志记录输出。



The screenshot of error in ternimal

终端机错误截图


更多回答

Do you have Webpack installed globally or locally?

Webpack是在全球安装还是在本地安装?

it would be helpful to show your code for start.js if possible

如果可能的话,展示start.js的代码会很有帮助

i have created a start.js file here in this Plnkr, please take a look. plnkr.co/edit/EbQDizLIzOzJJ3rML0DU?p=preview

我在这里创建了一个start.js文件,请看一下。Plnkr.co/EDIT/EbQDizLIzOzJJ3rML0DU?P=预览

@James i have installed it locally but i tried to install globally it showed me this error npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning ECONNABORTED: request to http://registry.npmjs.org/acorn failed, reason: connect ECONNABORTED 104.16.20.35:80 npm WARN registry Using stale package data from http://registry.npmjs.org/ due to a request error during revalidation. npm ERR! code ECONNABORTED npm ERR! errno ECONNABORTED npm ERR! request to http://registry.npmjs.org/@webassemblyjs%2fwasm-edit failed, reason: connect ECONNABORTED 104.16.20.35:80

@James我已经在本地安装了它,但我尝试全局安装它,它显示了这个错误npm warn注册表意外警告http://registry.npmjs.org/:其他警告ECONNABORTED:请求http://registry.npmjs.org/acorn失败,原因:CONNECT ECONNABORTED 104.16.20.35:80NPM WARN注册表使用来自http://registry.npmjs.org/的过时程序包数据,因为在重新验证过程中出现请求错误。NPM错误!代码ECONNABORTED NPM错误!错误:错误,错误!请求http://registry.npmjs.org/@webassemblyjs%2fwasm-edit失败,原因:CONNECT ECONNABORTED 104.16.20.35:80

@GulzarYousaf looks like you are trying to connect over an insecure connection (http), you'll need to check your npm settings. However, local is fine, can you post your package.json?

@GulzarYousaf看起来您正在尝试通过不安全的连接(Http)进行连接,您需要检查您的NPM设置。不过,本地的也可以,你能把你的Package.json贴出来吗?

优秀答案推荐

I ran into a problem with this same symptom after upgrading all of my node modules including react and redux, but in particular react-dev-utils to v8.0.0. The createCompiler() function has been changed to expect an object rather than multiple parameters (I guess this will provide greater flexibility in the future).

在将我的所有节点模块升级到v8.0.0之后,我遇到了同样的症状,包括reaction和redux,尤其是action-dev-utils。CreateCompiler()函数已被更改为需要一个对象,而不是多个参数(我想这将在未来提供更大的灵活性)。



I changed my start.js from:

我将start.js从:



const compiler = createCompiler(webpack, config, appName, urls, useYarn);


to:

致:



const compiler = createCompiler({ webpack, config, appName, urls, useYarn });


Simple npm install command worked form me

我使用了简单的NPM安装命令


更多回答

Worked like a charm - Thanks for sharing the solution!

工作起来很有魅力-感谢分享解决方案!

Had the exact same issue. I was wondering what caused it and even checked out a previous build wondering if I needed to revert any dependency updates for a last-known version. Your simple fix worked like a charm. OP, I'd make this the accepted answer.

也有同样的问题。我想知道是什么导致了它,甚至签出了以前的版本,想知道我是否需要恢复最新版本的任何依赖项更新。你简单的解决办法就像魔咒一样有效。哦,我会把这个作为公认的答案。

Did not work for me. "react-dev-utils": "^9.0.1". Any suggestions?

对我不起作用。“action-dev-utils”:“^9.0.1”。有什么建议吗?

@Akhilesh it's because of one or both of the last boolean parameters, mine was like this: const compiler = createCompiler({ webpack, config, appName, urls, false, false }); Either remove them, or make sure you pass them like useYarn: false... or use a variable with the same name like in this answer useYarn and useTypeScript.

@AkHilesh这是因为最后两个布尔参数中的一个或两个,我的是这样的:const编译器=createCompiler({webpack,CONFIG,appName,URL,FALSE,FALSE});要么删除它们,要么确保像useYarn:False一样传递它们...或者使用具有相同名称的变量,如此答案中的useYarn和useTypeScrip。

Unfortunately this did not work for me. I received TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined after making the changes suggested in this answer.

不幸的是,这对我不起作用。我收到TypeError[ERR_INVALID_ARG_TYPE]:“Path”参数必须是字符串类型。在进行此答案中建议的更改后收到的未定义。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com