【问题标题】:webpack' is not recognized as an internal or external commandwebpack' 未被识别为内部或外部命令
【发布时间】:2018-08-20 22:43:10
【问题描述】:

我正在尝试运行npm run build,它给了我以下错误:

'webpack' is not recognized as an internal or external command,

我尝试删除 node_modules 文件夹并运行:npm install 但这并没有解决问题。 有没有人有这个问题的经验并且可以提出解决方案?

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.1.0
3 info using node@v10.5.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle %APPLICATIONNAME%.website@1.0.0~prebuild: %APPLICATIONNAME%.website@1.0.0
6 info lifecycle %APPLICATIONNAME%.website@1.0.0~build: %APPLICATIONNAME%.website@1.0.0
7 verbose lifecycle %APPLICATIONNAME%.website@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle %APPLICATIONNAME%.website@1.0.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\%USER%\source\repos\%APPLICATIONNAME%\%APPLICATIONNAME%\%APPLICATIONNAME%.Website\node_modules\.bin;C:\Users\%USER%\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\%USER%\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Git\cmd;C:\Program Files (x86)\dotnet;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\WINDOWS\System32\OpenSSH;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Git\cmd;C:\Program Files (x86)\dotnet;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\WINDOWS\System32\OpenSSH;C:\Users\%USER%\AppData\Local\Microsoft\WindowsApps;C:\Users\%USER%\.dotnet\tools;C:\Users\%USER%\AppData\Roaming\npm;C:\Users\%USER%\AppData\Local\Microsoft\WindowsApps;C:\Users\%USER%\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle %APPLICATIONNAME%.website@1.0.0~build: CWD: C:\Users\%USER%\source\repos\%APPLICATIONNAME%\%APPLICATIONNAME%\%APPLICATIONNAME%.Website
10 silly lifecycle %APPLICATIONNAME%.website@1.0.0~build: Args: [ '/d /s /c',
10 silly lifecycle   'webpack --config webpack.config.js --progress --profile' ]
11 silly lifecycle %APPLICATIONNAME%.website@1.0.0~build: Returned: code: 1  signal: null
12 info lifecycle %APPLICATIONNAME%.website@1.0.0~build: Failed to exec build script
13 verbose stack Error: %APPLICATIONNAME%.website@1.0.0 build: `webpack --config webpack.config.js --progress --profile`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:961:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
14 verbose pkgid %APPLICATIONNAME%.website@1.0.0
15 verbose cwd C:\Users\%USER%\source\repos\%APPLICATIONNAME%\%APPLICATIONNAME%\%APPLICATIONNAME%.Website
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v10.5.0
19 verbose npm  v6.1.0
20 error code ELIFECYCLE
21 error errno 1
22 error %APPLICATIONNAME%.website@1.0.0 build: `webpack --config webpack.config.js --progress --profile`
22 error Exit status 1
23 error Failed at the reptune.website@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

【问题讨论】:

  • 你的 package.json 中有"webpack": "4.16.5"(或任何版本)吗?

标签: npm npm-install


【解决方案1】:

如果没有更多上下文很难判断,但如果您的代码使用的是较新版本的 webpack,请确保您还安装了 webpack 命令行工具,这些工具现在位于单独的 npm 模块中,webpack-cli。

【讨论】:

    猜你喜欢
    • 2019-01-31
    • 1970-01-01
    • 2014-04-29
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 2013-10-11
    • 2013-01-25
    • 2016-10-01
    相关资源
    最近更新 更多