我刚刚按照 ionic 框架网站上的说明安装了 npm 和 ionic,一旦我开始一个新项目,我就会收到这些错误

Posted

技术标签:

【中文标题】我刚刚按照 ionic 框架网站上的说明安装了 npm 和 ionic,一旦我开始一个新项目,我就会收到这些错误【英文标题】:I have just installed npm and ionic following the instructions on ionic framework website and as soon as i start a new project i get these errors 【发布时间】:2021-05-08 08:47:40 【问题描述】:

我是 Ionic 框架的新手。。

离子信息

Ionic:

   Ionic CLI : 6.12.4

Utility:
   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v15.7.0
   npm    : 7.4.3
   OS     : macOS Big Sur

% ionic start

?框架:角 ?项目名称:应用 ?入门模板:空白

✔ Preparing directory ./aps in 887.30μp
✔ Downloading and extracting blank starter in 143.10ms
? Integrate your new app with Capacitor to target native ios and android? No

Installing dependencies may take several minutes.

  ──────────────────────────────────────────────────────────────

        Ionic Appflow, the mobile DevOps solution by Ionic

           Continuously build, deploy, and ship apps ????
        Focus on building apps while we automate the rest ????

                 ????  https://ion.link/appflow  ????

  ──────────────────────────────────────────────────────────────
> npm i

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: aps@0.0.1
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR!   peer typescript@">=4.0 <4.2" from @angular/compiler-cli@11.1.2
npm ERR!   node_modules/@angular/compiler-cli
npm ERR!     peer @angular/compiler-cli@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@"~4.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/<username>/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/<username>/.npm/_logs/2021-02-04T03_19_54_834Z-debug.log
[ERROR] An error occurred while running subprocess npm.
        
        npm i exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more
        information.

【问题讨论】:

你有没有试过编辑 package.json: typescript: 4.0 到 4.2 然后重新运行看看会发生什么 检查您需要运行哪个命令才能开始。也许是离子服务或离子安装?因为对于每个 npm 项目,您都有两个步骤,安装和启动。此外,文档也可能有所帮助:ionicframework.com/docs/intro/cli 在 package.json 中的 "typescript": "&gt;=4.0 &lt;4.2" 我应该如何更改它? 【参考方案1】:

我遇到了同样的问题。运行ionic start 后,我可以在项目文件夹中运行npm install --force 并安装@angular-devkit/build-angular@0.1100.7。我相信这是角度方面的兼容性问题。我确实确认我能够在本地为该项目服务。但是,由于可能与 @angular-devkit/build-angular@0.1100.7 和您当前运行的 typescript 版本发生冲突,我不会认为这是一个永久的解决方案。

【讨论】:

以上是关于我刚刚按照 ionic 框架网站上的说明安装了 npm 和 ionic,一旦我开始一个新项目,我就会收到这些错误的主要内容,如果未能解决你的问题,请参考以下文章

应用程序运行时隐藏 Ionic 应用程序上的推送通知

Ionic 4+Vue JS 汉堡菜单

ionic的安装

离子推送服务返回 301

PostGIS 错误:类型“地理”不存在

如何在 Ionic 框架中发送推送通知?