node.js - 使用 Angular cli 创建 Angular 项目时出现问题

标签 node.js angular

我使用的是 Windows 10,使用 angular cli 从来没有遇到过任何问题 为了创建和运行 Angular 项目,今天我注意到我仍然能够使用 ngserve 运行旧项目,但是当我尝试使用 ng new *name* 创建新项目时,我创建日志末尾有这些警告:

npm WARN rollback Rolling back minimist@1.2.0 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Talon\Desktop\angular\angular-essentials-two\routing\node_modules\fsevents\node_modules\rc\node_modules'
npm WARN @angular-devkit/schematics@0.0.51 requires a peer of @angular-devkit/core@0.0.28 but none is installed. You must install peer dependencies yourself.
npm WARN @schematics/angular@0.1.16 requires a peer of @angular-devkit/core@0.0.28 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

如果我然后尝试进入该项目并运行 ngserve 我有

module.js:540
throw err;
^

Error: Cannot find module '@angular-devkit/core'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Talon\Desktop\angular\angular-essentials-two\routing\node_modules\@angular-devkit\schematics\src\tree\virtual.js:10:16)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)

我用谷歌搜索了一下,发现了这个fix ,但是如果我尝试运行 npm install -g @angular-devkit/core 我有

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\@angular-devkit\core\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular-devkit/core@0.0.28
updated 1 package in 9.351s

如果我ng服务,我也会遇到同样的找不到模块'@angular-devkit/core'错误。

我不知道这是否是巧合,但在几天前的最新 Windows 10 更新之前,一切都工作正常。 我当前的 Angular cli 版本是 1.6.3

最佳答案

npm install --save-dev @angular-devkit/core 将解决这个问题

关于node.js - 使用 Angular cli 创建 Angular 项目时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48359038/

相关文章:

javascript - 如何处理服务器( Node js)中表单的数据?

javascript - 压缩 JSON 字符串? (以及一般的字符串)

Node.js:如何将流读入缓冲区?

node.js - Slack API 上传图像或视频

javascript - 类型 'update' 上不存在属性 'Observable<{}>'。火力地堡 5 Angular 火 2 5

javascript - 将 Service Worker 安装到 Angular 4 应用程序 - 无需 Angular CLI

angular - 来自 Angular Route Guard 的 Web Api 调用

javascript - 使用可选对象解析 JSON?

Angular2 我怎样才能覆盖提供者

Angular2 本地组件/模板重用