NPM Build因UglifyJs错误而失败 - 意外的令牌:名称(上下文)

时间:2018-06-08 03:30:47

标签: node.js npm genesis

我正在尝试从PHPStorm中构建一个REACTJS项目。开发人员告诉我它在他们的环境中构建良好。它对我来说也很好,但现在我得到以下错误:

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @genesisui/react@1.8.11 build: `webpack -p --progress --env.prod`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @genesisui/react@1.8.11 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Robert\AppData\Roaming\npm-cache\_logs\2018-06-08T03_10_46_084Z-debug.log

Process finished with exit code 2

此输出上方的错误为:

ERROR in index.bundle.js from UglifyJs
Unexpected token: name (context) [./node_modules/striptags/src/striptags.js:26,0][index.bundle.js:112143,12]

ERROR in index.bundle.js from UglifyJs
Unexpected token: name (context) [./node_modules/striptags/src/striptags.js:26,0][index.bundle.js:112143,12]

完整的npm-debug.log是:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build',
1 verbose cli   '--scripts-prepend-node-path=auto' ]
2 info using npm@6.1.0
3 info using node@v10.4.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle @genesisui/react@1.8.11~prebuild: @genesisui/react@1.8.11
6 info lifecycle @genesisui/react@1.8.11~build: @genesisui/react@1.8.11
7 verbose lifecycle @genesisui/react@1.8.11~build: unsafe-perm in lifecycle true
8 verbose lifecycle @genesisui/react@1.8.11~build: PATH: C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Robert\Projects\my-project\client\node_modules\.bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Python27\;C:\Python27\Scripts;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\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft\Web Platform Installer\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\xampp\mysql\bin\;C:\Users\Robert\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\GitExtensions\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\Amazon\AWSCLI\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\nodejs\
9 verbose lifecycle @genesisui/react@1.8.11~build: CWD: C:\Users\Robert\Projects\my-project\client
10 silly lifecycle @genesisui/react@1.8.11~build: Args: [ '/d /s /c', 'webpack -p --progress --env.prod' ]
11 silly lifecycle @genesisui/react@1.8.11~build: Returned: code: 2  signal: null
12 info lifecycle @genesisui/react@1.8.11~build: Failed to exec build script
13 verbose stack Error: @genesisui/react@1.8.11 build: `webpack -p --progress --env.prod`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files (x86)\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 (x86)\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 @genesisui/react@1.8.11
15 verbose cwd C:\Users\Robert\Projects\my-project\client
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build" "--scripts-prepend-node-path=auto"
18 verbose node v10.4.0
19 verbose npm  v6.1.0
20 error code ELIFECYCLE
21 error errno 2
22 error @genesisui/react@1.8.11 build: `webpack -p --progress --env.prod`
22 error Exit status 2
23 error Failed at the @genesisui/react@1.8.11 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

有人能指出我正确的方向来解决这个问题吗?

修改

我最初发布了一个过时的npm-debug.log。问题现在包括正确的日志。

1 个答案:

答案 0 :(得分:1)

Aa在日志中建议,您可以尝试将您的节点以及您的npm更新到最新版本,并在删除node_modules后再次尝试构建