You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Angular 12项目本地安装适配版本的npm?

问题:为Angular 12项目本地安装专属npm版本

现有项目情况

  • 关联Java的Angular 14项目

    • 依赖安装方式:通过Maven的frontend-maven-plugin在项目本地安装Node.js和npm,插件配置如下:
      com.github.eirslett:frontend-maven-plugin:install-node-and-npm
         {nodeVersion: ${node.version}, npmVersion: ${npm.version}, 
         workingDirectory: "${basedir}/${contexte-client}"}
      
      com.github.eirslett:frontend-maven-plugin:npm{arguments: install}
      com.github.eirslett:frontend-maven-plugin:npm{arguments: run buildProduction}
      
    • 配置参数:node.version=v18.12.1、npm.version=8.19.2,安装目录为~/dev/Java/comptes-france/metier-et-gestion/AdapterInboundWebEtude/etude
    • 运行状态:生产构建和本地ng serve均正常
    • 全局环境:/usr/bin/下装有Node.js 18.13.0,可用于命令行执行ng serve
  • 纯Angular 12学习项目

    • 问题触发:Debian从11升级到12后,ng serve出现webpack加密信封相关报错;删除node_modules后重新执行ng serve,报错Cannot find module '@angular-devkit/build-angular/package.json'
    • 后续问题:执行npm update时提示bash: npm : command not found,怀疑之前的npm存在于已删除的node_modules中

需求与疑问

希望为该Angular 12项目单独安装适配的npm版本,仅局限于项目目录内,不全局安装,同时保留Angular 14项目使用的npm 8.19.2版本。这种类似frontend-maven-plugin的本地安装思路是否可行?或者我的思路存在错误?

内容的提问来源于stack exchange,提问作者Marc Le Bihan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 19:43:25