gpt4 book ai didi

node.js - 弹出 create-react-app 更新包后, "webpack is not a function"

转载 作者:行者123 更新时间:2023-12-05 02:58:31 25 4
gpt4 key购买 nike

在实验样板项目上使用旧版本的 create-react-app,我需要更新包才能继续。我认为最好的方法是弹出 create-react-app,但现在整个程序都无法运行。这是 Nodemon 之后的输出:

[1] Failed to compile.
[1]
[1] webpack is not a function
[1]
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! client@0.1.0 start: `node scripts/start.js`
[1] npm ERR! Exit status 1
[1] npm ERR!
npm ERR! Failed at the client@0.1.0 start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR! /Users/gabrielkunkel/.npm/_logs/2019-11-20T23_19_58_956Z-debug.log

如果我搜索完整的日志,webpack 根本不会出现。我希望我能将其缩小到有用的范围。

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/bin/node',
1 verbose cli '/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/bin/npm',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm@6.13.1
3 info using node@v12.8.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle client@0.1.0~prestart: client@0.1.0
6 info lifecycle client@0.1.0~start: client@0.1.0
7 verbose lifecycle client@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~start: PATH: /Users/gabrielkunkel/.nvm/versions/node/v12.8.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/gabrielkunkel/Documents/DevCodeCamp/Capstone/kunkl-project/client/node_modules/.bin:/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/gabrielkunkel/Documents/DevCodeCamp/Capstone/kunkl-project/node_modules/.bin:/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/dotnet:~/.dotnet/tools:/usr/local/git/bin:/usr/local/MacGPG2/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/gabrielkunkel/.rvm/bin:/Users/gabrielkunkel/.rvm/bin
9 verbose lifecycle client@0.1.0~start: CWD: /Users/gabrielkunkel/Documents/DevCodeCamp/Capstone/kunkl-project/client
10 silly lifecycle client@0.1.0~start: Args: [ '-c', 'node scripts/start.js' ]
11 silly lifecycle client@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle client@0.1.0~start: Failed to exec start script
13 verbose stack Error: client@0.1.0 start: `node scripts/start.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:203:13)
13 verbose stack at ChildProcess.<anonymous> (/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:203:13)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid client@0.1.0
15 verbose cwd /Users/gabrielkunkel/Documents/DevCodeCamp/Capstone/kunkl-project/client
16 verbose Darwin 16.7.0
17 verbose argv "/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/bin/node" "/Users/gabrielkunkel/.nvm/versions/node/v12.8.1/bin/npm" "start"
18 verbose node v12.8.1
19 verbose npm v6.13.1
20 error code ELIFECYCLE
21 error errno 1
22 error client@0.1.0 start: `node scripts/start.js`
22 error Exit status 1
23 error Failed at the client@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

我尝试清理 node_modules 并根据建议重新安装它们 here ,问题略有不同。我什至尝试在全局安装 webpack。

我希望只修复一些小问题并继续或至少理解为什么它不能运行 webpack。实际上,除非您能帮助我,否则我将保存所有文件并重新运行 create-react-app。

最佳答案

最好的办法是在单独的文件夹中构建一个新的 create-react-app,然后运行 ​​npm run eject。然后,您使用版本控制来查看 package.json 以及配置和脚本文件夹/文件中的差异。更新您的 Node 模块以匹配新创建的 create-react-app 并复制/粘贴配置文件。

关于node.js - 弹出 create-react-app 更新包后, "webpack is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58965044/

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