【问题标题】:Is there any tip to solve the error "The serve command requires to be run in an Angular project, but a project definition could not be found."是否有任何提示可以解决“服务命令需要在 Angular 项目中运行,但找不到项目定义”错误。
【发布时间】:2023-03-13 11:55:01
【问题描述】:

是否有解决“服务命令需要在 Angular 项目中运行,但找不到项目定义”错误的提示。 ?

PS C:\angular\pro\toitsu-view> ng serve
The serve command requires to be run in an Angular project, but a project definition could not be found.
PS C:\angular\pro\toitsu-view> npm install
npm WARN toitsu-view@1.0.0 No repository field.
npm WARN toitsu-view@1.0.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: amdefine@1.0.1 (node_modules\amdefine):
npm WARN network SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/amdefine failed, reason: connect ETIMEDOUT 93.184.216.34:8082
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: source-map@0.1.43 (node_modules\ast-transform\node_modules\source-map):
npm WARN network SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/source-map failed, reason: connect ETIMEDOUT 93.184.216.34:8082

npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/ansi-gray failed, reason: connect ETIMEDOUT 93.184.216.34:8082
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xaxanoulis\AppData\Roaming\npm-cache\_logs\2021-08-18T12_15_16_126Z-debug.log
PS C:\angular\pro\toitsu-view>

【问题讨论】:

    标签: angular typescript visual-studio-code


    【解决方案1】:

    更改运行 ng serve 命令的路径并尝试。它应该在您看到 src 文件夹的 Angular 项目中运行

    【讨论】:

    【解决方案2】:

    我认为您在错误的目录中,并且这没有被注册为 Angular 项目。您应该在包含以下文件的目录中导航

    1. angular.json

    这将是您的应用程序根文件夹。导航到此处后,运行 npm install,然后运行 ​​npm start /ng serve

    类似的东西。 我将在primeng-testing 中导航以运行上述这些命令。

    【讨论】:

    • 如果您可以共享您的文件夹目录,那将是很好的识别问题
    • C:\angular\pro\toitsu-view\src\app
    • 那么,您在 C:\angular\pro\toitsu-view\src\app 中有 node_modules 和 angular.json 文件吗?还是在 C:\angular\pro\toitsu-view 里面?
    猜你喜欢
    • 2020-04-19
    • 2021-04-13
    • 2019-04-05
    • 1970-01-01
    • 1970-01-01
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    • 2020-03-19
    相关资源
    最近更新 更多