简体   繁体   English

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

[英]NodeJS - How to properly install and run Webpack on Windows 10?

I downloaded existing Web project and tried to run: webpack --watch --progress 我下载了现有的Web项目并尝试运行:webpack --watch --progress

but it keeps saying: 但它一直在说:

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' }

Does WebPack require specific NPM/Node version? WebPack是否需要特定的NPM /节点版本? (maybe newer version is not compatible with older one).. (也许新版本与旧版本不兼容)。

https://stackoverflow.com/a/41305211 https://stackoverflow.com/a/41305211

Oleg Pro's help did the trick for me, specifically putting node_modules/.bin in my path as he describes in part 3. Oleg Pro的帮助帮了我node_modules/.bin ,特别是如他在第3部分中所述,将node_modules/.bin放在我的路径中。

With my versions of webpack (4.29.0) and Node (v10.15.0), I didn't find node_modules/.bin/webpack-cmd (as he specifies in 1.) in my project directory; 在我的webpack(4.29.0)和Node(v10.15.0)版本中,我在项目目录中找不到node_modules/.bin/webpack-cmd (如他在1中指定的那样)。 I found node_modules/.bin/webpack-cli . 我发现了node_modules/.bin/webpack-cli

The install appears to work, as I then used webpack to install Vue, which in turn generated app.vue and hello_vue.js files. 安装工作正常,然后我使用webpack安装Vue,Vue又生成了app.vuehello_vue.js文件。 However, vue --version returns vue:command not found, so I'm adopting a wait and see attitude. 但是, vue --version返回找不到的vue:command ,因此我采用了一种观望的态度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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