开发者问题收集

项目未在 Angular 中运行

2021-05-02
834

我的 Angular 项目未构建。当我运行应用程序 (ng serve -o) 时,它显示此消息:

`发生未处理的异常:找不到模块 '@angular-devkit/build-angular/package.json' 需要堆栈:

  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\architect\node\node-modules-architect-host.js
  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\architect\node\index.js
  • C:\用户\用户\应用数据\漫游\npm\node_modules@angular\cli\models\architect-command.js
  • C:\用户\用户\应用数据\漫游\npm\node_modules@angular\cli\commands\serve-impl.js
  • C:\用户\用户\应用数据\漫游\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\to ols\export-ref.js
  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\tools\index.js
  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\utilities\json-schema.js
  • C:\Users\User\AppData\Roaming\npm\node_mod ules@angular\cli\models\command-runner.js
  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\lib\cli\index.js
  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
  • C:\Users\User\AppData\Roaming\npm\node_modules@angular\cli\bin\ng 有关更多详细信息,请参阅“C:\Users\User\AppData\Local\Temp\ng-2zf3VF\angular-errors.log”。`

当我尝试安装 npm 时 -

`npm ERR! 代码 1

npm ERR!路径 H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-sass

npm ERR! 命令失败

npm ERR! 命令 C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js

npm ERR! 正在构建:C:\Program Files\nodejs\node.exe H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=

npm ERR! gyp 信息如果以 ok 结尾则表示有效

npm ERR! gyp 动词 cli [

npm ERR! gyp 动词 cli 'C:\Program Files\nodejs\node.exe',

npm ERR!gyp 动词 cli 'H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-gyp\bin\node-gyp.js',

npm ERR!gyp 动词 cli 'rebuild',

npm ERR!gyp 动词 cli '--verbose',

npm ERR!gyp 动词 cli '--libsass_ext=',

npm ERR!gyp 动词 cli '--libsass_cflags=',

npm ERR!gyp 动词 cli '--libsass_ldflags=',

npm ERR! gyp verb cli '--libsass_library='

npm ERR! gyp verb cli ]

npm ERR! gyp 信息使用 [email protected]

npm ERR! gyp 信息使用 [email protected] | win32 | x64

npm ERR! gyp verb 命令 rebuild []

npm ERR! gyp verb 命令 clean []

npm ERR! gyp verb clean 删除“build”目录

npm ERR! gyp verb 命令 configure []

npm ERR! gyp verb check python 检查 PATH 中是否存在 Python 可执行文件“c:\python27\python.exe”

npm ERR! gyp verb which 失败 错误:未找到:c:\python27\python.exe

npm ERR! gyp verb which 失败于 getNotFoundError(H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:13:12)

npm ERR! gyp verb which 失败于 F(H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:68:19)

npm ERR! gyp 动词 which 失败于 E(H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:80:29)

npm ERR!gyp 动词 which 失败于 H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:89:16

npm ERR!gyp 动词 which 失败于 H:\JavaScript\Practise\Angular\gkb-app\node_modules\isexe\index.js:42:5

npm ERR!gyp 动词 which 失败于 H:\JavaScript\Practise\Angular\gkb-app\node_modules\isexe\windows.js:36:5

npm ERR! gyp 动词 which 于 FSReqCallback.oncomplete 失败(fs.js:183:21)

npm ERR! gyp 动词 which 于 c:\python27\python.exe 失败 错误:未找到:c:\python27\python.exe

npm ERR! gyp 动词 which 于 getNotFoundError 失败(H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:13:12)

npm ERR! gyp 动词 which 于 F 失败(H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:68:19)

npm ERR! gyp 动词 which 失败于 E(H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:80:29)

npm ERR!gyp 动词 which 失败于 H:\JavaScript\Practise\Angular\gkb-app\node_modules\which\which.js:89:16

npm ERR!gyp 动词 which 失败于 H:\JavaScript\Practise\Angular\gkb-app\node_modules\isexe\index.js:42:5

npm ERR!gyp 动词 which 失败于 H:\JavaScript\Practise\Angular\gkb-app\node_modules\isexe\windows.js:36:5

npm ERR! gyp 动词 which 在 FSReqCallback.oncomplete (fs.js:183:21) 处失败 {

npm ERR! gyp 动词 which 失败代码:“ENOENT”

npm ERR! gyp 动词 which 失败

npm ERR! gyp 动词找不到“c:\python27\python.exe”。正在检查 python 启动器

npm ERR! gyp 动词找不到“c:\python27\python.exe”。正在猜测位置

npm ERR! gyp 动词确保文件存在:C:\Python27\python.exe

npm ERR! gyp ERR! 配置错误

npm ERR! gyp ERR! stack 错误:找不到 Python 可执行文件“c:\python27\python.exe”,您可以设置 PYTHON 环境变量。

npm ERR! gyp ERR! stack at PythonFinder.failNoPython (H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-gyp\lib\configure.js:484:19)

npm ERR! gyp ERR! stack at PythonFinder. (H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-gyp\lib\configure.js:509:16)

npm ERR! gyp ERR! stack at callout (H:\JavaScript\Practise\Angular\gkb-app\node_modules\graceful-fs\polyfills.js:295:20)

npm ERR! gyp ERR! 堆栈位于 FSReqCallback.oncomplete (fs.js:183:21)

npm ERR! gyp ERR! 系统 Windows_NT 10.0.17763

npm ERR! gyp ERR! 命令 “C:\Program Files\nodejs\node.exe” “H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-gyp\bin\node-gyp.js” “rebuild” “--verbose” “--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="

npm ERR! gyp ERR! cwd H:\JavaScript\Practise\Angular\gkb-app\node_modules\node-sass

npm ERR! gyp ERR! node -v v14.16.1

npm ERR! gyp ERR! node-gyp -v v3.8.0

npm ERR! gyp ERR! 不正常

npm ERR! 构建失败,错误代码:1

npm ERR! 可以在以下位置找到此运行的完整日志:

npm ERR! C:\Users\User\AppData\Local\npm-cache_logs\2021-05-02T02_06_34_403Z-debug.log ` 我尝试了几种解决方案,但这些都不起作用。请看一下。谢谢

1个回答

NodeJs 14 的 Node-Sass 版本至少应为 v4.14.0。 如果您正在运行旧代码,只需将您的 NodeJs 切换到 V12,然后全局安装 angular,然后 npm 安装该项目。

Adnan
2021-05-02