【问题标题】:Angular 2-4 SETUP not able to run on windowsAngular 2-4 SETUP 无法在 Windows 上运行
【发布时间】:2018-01-16 14:00:06
【问题描述】:

我是 Angular 2/4 的新手,在我遵循 https://github.com/angular/angular-cli 的命令之前它运行良好。我在我的机器上运行 Angular 2-4。但是在一些 Windows 更新之后,我不再能够运行 Angular。它一直在说

我在 github anugular CLI 安装中运行了以下命令并执行了其他命令

>npm install -g @angular/cli or sometimes I ran npm install -g @angular/cli@latest
npm install
ng serve

当我运行 npm install -g @angular/cli 时。这是下面的消息。

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\@angular\cli\node_modules\chokidar\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"})
npm WARN @schematics/angular@0.1.13 requires a peer of @angular-devkit/schematics@0.0.46 but none was installed.
npm WARN @schematics/schematics@0.0.13 requires a peer of @angular-devkit/schematics@0.0.46 but none was installed.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli@latest"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! path C:\Users\kislam\AppData\Roaming\npm\node_modules\@angular\cli
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\kislam\AppData\Roaming\npm\node_modules\@angular\cli' -> 'C:\Users\kislam\AppData\Roaming\
npm\node_modules\@angular\.cli.DELETE'
npm ERR!     at moveAway (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:38:5)
npm ERR!     at destStatted (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:27:7)
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:267:18
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\kislam\AppData\Roaming\npm\node_modules\@angular\cli' -> 'C:\Users\kislam\AppData\Roaming\
npm\node_modules\@angular\.cli.DELETE'
npm ERR!     at Error (native)
npm ERR!  Error: EPERM: operation not permitted, rename 'C:\Users\kislam\AppData\Roaming\npm\node_modules\@angular\cli' -> 'C:\Users\kislam\AppData\Roaming
\npm\node_modules\@angular\.cli.DELETE'
npm ERR!     at moveAway (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:38:5)
npm ERR!     at destStatted (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:27:7)
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:267:18
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\kislam\AppData\Roaming\npm\node_modules\@angular\cli' -> 'C:\Users\kislam\AppData\Roaming\
npm\node_modules\@angular\.cli.DELETE'
npm ERR!     at Error (native)
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\kislam\Documents\Angular\dynamicform-jan72017\npm-debug.log
npm ERR! code 1

之后我跑了:

npm 安装 服务

我也按照这里的步骤https://github.com/angular/angular-cli

似乎没有任何效果

错误我在运行ng serve时遇到错误

C:\Temp\angular\dynamicformjan72017>ng serve
'ng' is not recognized as an internal or external command,
operable program or batch file.

我已经包含了节点模块权限的屏幕抓取。 有人可以帮忙吗?我正在运行 windows 7 专业版

【问题讨论】:

  • 你的 ">npm install -g @angular/cli" 是如何结束的?有没有错误?
  • 您对问题缺乏描述的解释过于笼统...尝试向我们提供您的 Angular cli 版本以及您尝试执行的确切步骤...
  • 您在哪个版本的节点上运行? node -v。好像你的安装不成功。也可能是你的 bin 目录被移动了。

标签: angular angular-cli


【解决方案1】:

您的全局安装的@angular/cli 包似乎无法正常工作。

您应该尝试卸载/重新安装它或更改文件夹选项(只读)。通常EPERM错误是由于windows的读/写权限引起的。

此链接将帮助您正确执行此操作:https://github.com/angular/angular-cli#updating-angular-cli

npm uninstall -g @angular/cli 
npm cache clean
npm install -g @angular/cli

【讨论】:

  • 我从 C 盘更改为 Documents 文件夹。还是不行
  • 这不是关于移动它们,而是关于文件夹权限。检查包含node_modules的文件夹npm是否不在read-only
  • 谢谢,我会试试看,为什么不识别 ng serve .. ..ng serve 'ng' 不被识别为内部或外部命令、可运行程序或批处理文件。
  • 我已经发布了屏幕抓取 .angular 仍然无法识别 ng serve
  • 我猜那是因为您移动了文件夹...它与 windows CMD 和 PATH 变量有关。由于您移动了文件夹,因此链接到 windows CMD 的 PATH 很可能不再起作用。您应该真正清理所有这些并在全局范围内重新安装 angular/cli。
猜你喜欢
  • 2019-04-13
  • 1970-01-01
  • 2017-03-22
  • 2018-02-27
  • 1970-01-01
  • 1970-01-01
  • 2016-02-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多