gpt4 book ai didi

node.js - NodeJS - 如何在 Windows 10 上正确安装和运行 Webpack?

转载 作者:太空宇宙 更新时间:2023-11-04 01:39:31 24 4
gpt4 key购买 nike

我下载了现有的 Web 项目并尝试运行:webpack --watch --progress

但它一直说:

webpack --watch --progress
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
npm WARN @ngtools/webpack@1.10.2 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror@1.1.3 requires a peer of @angular/core@^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror@1.1.3 requires a peer of @angular/forms@^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror@1.1.3 requires a peer of @angular/common@^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@2.11.3 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ webpack-cli@3.1.2
added 2 packages from 2 contributors, removed 1 package, updated 3 packages and audited 24726 packages in 16.453s
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
{ Error: Cannot find module 'webpack-cli'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at runCommand.then (...\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:142:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }

WebPack 是否需要特定的 NPM/Node 版本? (也许新版本与旧版本不兼容)..

最佳答案

https://stackoverflow.com/a/41305211

Oleg Pro 的帮助帮了我的忙,特别是按照他在第 3 部分中的描述,将 node_modules/.bin 放入我的路径中。

使用我的 webpack (4.29.0) 和 Node (v10.15.0) 版本,我在项目目录中没有找到 node_modules/.bin/webpack-cmd (如他在 1. 中指定的那样);我找到了node_modules/.bin/webpack-cli

安装似乎有效,因为我随后使用 webpack 安装 Vue,这又生成了 app.vuehello_vue.js 文件。但是,vue --version 返回 vue:command not found,所以我采取观望态度。

关于node.js - NodeJS - 如何在 Windows 10 上正确安装和运行 Webpack?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53379922/

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