gpt4 book ai didi

javascript - ng add @nguniversal/express-engine@next 时出错

转载 作者:行者123 更新时间:2023-12-04 16:32:07 26 4
gpt4 key购买 nike

问题
我一直在尝试通过运行“ng add @nguniversal/express-engine@next”为我的 Angular 项目添加 seo 功能,但不断收到错误

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/json-file'


我尝试重新安装@schematics/angular,但它显示相同的错误,请告知可以采取哪些措施来解决此问题。
Error for ng add @nguniversal/express-engine@next
错误日志
[error] Error: Cannot find module '@schematics/angular/utility/json-file'
Require stack:
- /Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/common/schematics/add/index.js
- /Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/express-engine/schematics/install/index.js
- /Users/ooicw/Documents/roomer-app/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /Users/ooicw/Documents/roomer-app/node_modules/@angular-devkit/schematics/tools/index.js
- /Users/ooicw/Documents/roomer-app/node_modules/@angular/cli/utilities/json-schema.js
- /Users/ooicw/Documents/roomer-app/node_modules/@angular/cli/models/command-runner.js
- /Users/ooicw/Documents/roomer-app/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at /Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/common/schematics/add/index.js:32:25
at /Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/common/schematics/add/index.js:12:17
at Object.<anonymous> (/Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/common/schematics/add/index.js:18:3)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at /Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/express-engine/schematics/install/index.js:31:19
at /Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/express-engine/schematics/install/index.js:12:17
at Object.<anonymous> (/Users/ooicw/Documents/roomer-app/node_modules/@nguniversal/express-engine/schematics/install/index.js:18:3)

Angular CLI 版本
Angular CLI: 9.1.15
Node: 12.18.3
OS: darwin x64

Angular: 9.1.3
... common, compiler, compiler-cli, core, language-service
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: No

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.7
@angular-devkit/build-angular 0.901.12
@angular-devkit/build-optimizer 0.901.12
@angular-devkit/build-webpack 0.901.12
@angular-devkit/core 9.0.7
@angular-devkit/schematics 9.1.15
@angular/animations 9.1.9
@angular/cdk 9.2.4
@angular/cli 9.1.15
@angular/fire 6.0.0
@angular/flex-layout 9.0.0-beta.29
@angular/forms 9.1.9
@angular/material 9.2.4
@angular/platform-server 11.2.3
@angular/service-worker 9.1.11
@ngtools/webpack 9.1.12
@nguniversal/common 11.1.0-next.0
@nguniversal/express-engine 11.1.0-next.0
@schematics/angular 9.1.15
@schematics/update 0.901.15
rxjs 6.5.5
typescript 3.7.5
webpack 4.43.0

最佳答案

通过从 node_modules 中删除 @nguniversal 包并重新安装,可以解决此问题。
删除命令中的@next,因为只有Angular CLI 12 支持@next(使用的版本是Angular CLI 9。

关于javascript - ng add @nguniversal/express-engine@next 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66403597/

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