node.js - 由于依赖问题, ionic 启动失败

标签 node.js angular ionic-framework npm

我刚刚安装了 Ionic

npm install -g @ionic/cli
当我尝试运行时
ionic start ionic-test-app
初始化失败,出现 npm 依赖错误。
关于名为 postcss 的包的错误版本。
$ ionic start ionic-test-app

Pick a framework! 😁

Please select the JavaScript framework to use for your new app. To bypass this prompt next time,
supply a value for the --type option.

? Framework: Angular

Let's pick the perfect starter template! 💪

Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your
app. To bypass this prompt next time, supply template, the second argument to ionic start.

? Starter template: blank
? ./ionic-test-app exists. Overwrite? Yes
✔ Preparing directory ./ionic-test-app in 6.79ms
✔ Downloading and extracting blank starter in 188.52ms
? Integrate your new app with Capacitor to target native iOS and Android? Yes
> ionic integrations enable capacitor --quiet -- ionic-test-app io.ionic.starter
> npm i --save -E @capacitor/core@latest
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: postcss@8.2.14
npm ERR! node_modules/postcss
npm ERR!   postcss@"8.2.14" from @angular-devkit/build-angular@0.1102.13
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1102.4" from the root project
npm ERR!     peer @angular-devkit/build-angular@"^0.1102.4" from @ionic/angular-toolkit@3.1.1
npm ERR!     node_modules/@ionic/angular-toolkit
npm ERR!       dev @ionic/angular-toolkit@"^3.1.1" from the root project
npm ERR!   peer postcss@"^8.1.0" from autoprefixer@10.2.4
npm ERR!   node_modules/autoprefixer
npm ERR!     autoprefixer@"10.2.4" from @angular-devkit/build-angular@0.1102.13
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~0.1102.4" from the root project
npm ERR!       1 more (@ionic/angular-toolkit)
npm ERR!   9 more (css-loader, cssnano, postcss-import, postcss-loader, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer postcss@"^8.2.15" from cssnano-preset-default@5.1.0
npm ERR! node_modules/cssnano/node_modules/cssnano-preset-default
npm ERR!   cssnano-preset-default@"^5.0.1" from cssnano@5.0.2
npm ERR!   node_modules/cssnano
npm ERR!     cssnano@"5.0.2" from @angular-devkit/build-angular@0.1102.13
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~0.1102.4" from the root project
npm ERR!       1 more (@ionic/angular-toolkit)
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 /home/sekthor/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sekthor/.npm/_logs/2021-05-20T17_05_21_790Z-debug.log
[ERROR] An error occurred while running subprocess npm.
        
        npm i --save -E @capacitor/core@latest exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.

Installing dependencies may take several minutes.

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

         Ionic Advisory, tailored solutions and expert services by Ionic

                             Go to market faster 🏆
                    Real-time troubleshooting and guidance 💁
        Custom training, best practices, code and architecture reviews 🔎
      Customized strategies for every phase of the development lifecycle 🔮

                        👉  https://ion.link/advisory  👈

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


> npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: postcss@8.2.14
npm ERR! node_modules/postcss
npm ERR!   postcss@"8.2.14" from @angular-devkit/build-angular@0.1102.13
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1102.4" from the root project
npm ERR!     peer @angular-devkit/build-angular@"^0.1102.4" from @ionic/angular-toolkit@3.1.1
npm ERR!     node_modules/@ionic/angular-toolkit
npm ERR!       dev @ionic/angular-toolkit@"^3.1.1" from the root project
npm ERR!   peer postcss@"^8.1.0" from autoprefixer@10.2.4
npm ERR!   node_modules/autoprefixer
npm ERR!     autoprefixer@"10.2.4" from @angular-devkit/build-angular@0.1102.13
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~0.1102.4" from the root project
npm ERR!       1 more (@ionic/angular-toolkit)
npm ERR!   9 more (css-loader, cssnano, postcss-import, postcss-loader, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer postcss@"^8.2.15" from cssnano-preset-default@5.1.0
npm ERR! node_modules/cssnano/node_modules/cssnano-preset-default
npm ERR!   cssnano-preset-default@"^5.0.1" from cssnano@5.0.2
npm ERR!   node_modules/cssnano
npm ERR!     cssnano@"5.0.2" from @angular-devkit/build-angular@0.1102.13
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~0.1102.4" from the root project
npm ERR!       1 more (@ionic/angular-toolkit)
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 /home/sekthor/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sekthor/.npm/_logs/2021-05-20T17_05_28_760Z-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.
我对 npm 相当陌生,我似乎无法在此站点或互联网上的任何其他地方找到解决方案。
我已经尝试了 --force--legacy-peer-deps ,但收到同样的错误。
此错误的原因是什么,我该如何解决?
我的 Node 、npm 和 ionic 版本是:
$ node --version
v16.2.0
$ npm --version
7.13.0
$ ionic --version
6.16.1

最佳答案

这是我的第一个猜测 - 安装更新版本的 postcss ,但不幸的是,这并没有为我解决。解决方案是从 npm 降级的版本 7 到版本 6。

    npm install -g npm@6

关于node.js - 由于依赖问题, ionic 启动失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67625297/

相关文章:

Angular 获取当前路由

angular - 如何从ionic4中的 ionic 选择中删除小插入符号

angular - NgZone/Angular2/Ionic2 类型错误 : Cannot read property 'run' of undefined

node.js - 应用程序服务器和 REST API 服务器( Node )的单独端口

node.js - sequelize 迁移未运行

node.js - 如何一个接一个地运行相同的 promise NodeJs

angular - 在 Angular 9 中迁移到 Jest 会出现 "Zone is not defined"错误

python - 从 nodejs 运行 python 脚本并返回 json

angular - 禁用对 ngx-datatable 中特定列的选择

javascript - AngularJS + Google map 不显示标记