现有Angular项目使用Scully生成静态HTML报错,该如何排查解决?
问题说明
在现有Angular项目中接入Scully生成静态HTML时持续出现运行报错,检索公开技术内容未找到匹配解决方案,当前日志仅可显示npm脚本执行层面的退出码,无Scully进程抛出的核心错误信息,具体日志如下:
1 verbose cli [ 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 'scully' 1 verbose cli ] 2 info using npm@6.14.11 3 info using node@v14.16.0 4 verbose run-script [ 'prescully', 'scully', 'postscully' ] 5 info lifecycle ngw@3.3.21~prescully: ngw@3.3.21 6 info lifecycle ngw@3.3.21~scully: ngw@3.3.21 7 verbose lifecycle ngw@3.3.21~scully: unsafe-perm in lifecycle true 8 verbose lifecycle ngw@3.3.21~scully: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\laragon\apptest\test2\node_modules\.bin;C:\Python39\Scripts\;C:\Python39\;C:\Program Files (x86)\Common Files\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)\NVIDIA Corporation\PhysX\Common;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:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_67\bin;C:\Program Files\Java\jdk1.7.0_67\lib;C:\Program Files\Java\jdk1.7.0_79\bin;C:\Program Files\Java\jdk1.7.0_79\lib;C:\Dwimperl\perl\bin;C:\Dwimperl\perl\site\bin;C:\Dwimperl\c\bin;;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\shawn\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\shawn\AppData\Local\Programs\Python\Python35-32\;C:\Users\shawn\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;C:\Users\shawn\AppData\Roaming\npm;C:\Users\me\AppData\Local\Programs\Microsoft VS Code\bin 9 verbose lifecycle ngw@3.3.21~scully: CWD: C:\laragon\apptest\test2 10 silly lifecycle ngw@3.3.21~scully: Args: [ '/d /s /c', 'npm scully --' ] 11 silly lifecycle ngw@3.3.21~scully: Returned: code: 1 signal: null 12 info lifecycle ngw@3.3.21~scully: Failed to exec scully script 13 verbose stack Error: ngw@3.3.21 scully: `npm scully --` 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:332:16) 13 verbose stack at EventEmitter.emit (events.js:315:20) 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:315:20) 13 verbose stack at maybeClose (internal/child_process.js:1048:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) 14 verbose pkgid ngw@3.3.21 15 verbose cwd C:\laragon\apptest\test2 16 verbose Windows_NT 10.0.19041 17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "scully" 18 verbose node v14.16.0 19 verbose npm v6.14.11 20 error code ELIFECYCLE 21 error errno 1 22 error ngw@3.3.21 scully: `npm scully --` 22 error Exit status 1 23 error Failed at the ngw@3.3.21 scully script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]
分步排查操作指引
- 修正npm脚本配置:当前项目package.json中的
scully脚本值为npm scully --,会触发嵌套循环执行,直接替换为本地可执行文件调用scully即可消除循环逻辑。 - 跳过脚本封装直接运行Scully:在项目根目录的终端中执行
npx scully,绕过npm生命周期的封装逻辑直接启动Scully进程,抓取进程输出的真实错误栈,定位具体异常点。 - 校验版本匹配关系:当前环境为Node v14.16.0、npm 6.14.11,需适配Scully 1.0.x、Angular 12.x版本组合,跨版本混用依赖会直接导致进程无有效输出、异常退出。
- 排查Windows系统环境异常:确认项目存放路径无中文字符、无特殊空格格式,以管理员身份打开终端执行命令,规避系统权限拦截导致的进程终止。
- 清理依赖缓存:删除项目内的
node_modules目录、npm锁文件后重新执行依赖安装,再尝试运行Scully命令。
内容的提问来源于stack exchange,提问作者Sramirez
相关产品推荐
相关产品推荐

