【问题标题】:Need help in VS code with npm在使用 npm 的 VS 代码方面需要帮助
【发布时间】:2020-07-21 20:09:05
【问题描述】:

我需要使用 'ng serve' 来运行某些东西,但是当我尝试执行 sudo npm install 时,我得到了这个错误:

npm WARN bootstrap@4.5.0 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.5.0 requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.

audited 1499 packages in 15.548s

52 packages are looking for funding
  run `npm fund` for details

found 319 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

有人知道该怎么做才能使 ng serve 工作吗?当我现在尝试 ng serve 时,它​​说找不到命令。

【问题讨论】:

  • 那些不是错误。你的问题是 ng 没有安装。
  • 错误信息是不言自明的。 Bootstrap 需要 jquery 和 popper.js 才能工作,而你缺少这两个。首先尝试 npm install jquery 和 popperjs

标签: node.js npm visual-studio-code


【解决方案1】:

你应该先解决项目中的依赖问题

我认为npm install

那么当你所有的依赖都安装好后,你就可以走了。

ng serve 是角对吗?

你安装了npm install -g @angular/cli吗?

如果您想要更好的答案,您需要提供更多信息。

【讨论】:

  • 对不起,我对这一切有点陌生,当我执行 npm install 时,我收到与上面相同的消息。
  • 别着急,试试@CharukaHS评论里说的方式
【解决方案2】:

这不是 VS Code 问题。 您已经安装了引导程序,但没有安装引导程序依赖项。 您应该执行以下操作:

  1. 运行:npm install jquery popper.js

  2. 更新你的 angular.json 添加新安装的库:

     "styles": [
               "node_modules/bootstrap/dist/css/bootstrap.min.css",
               "node_modules/font-awesome/css/font-awesome.min.css",
               "src/styles.sass"
             ],
     "scripts": [
               "node_modules/jquery/dist/jquery.min.js",
               "node_modules/popper.js/dist/umd/popper.min.js",
               "node_modules/bootstrap/dist/js/bootstrap.min.js"
             ]
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-04
    • 2012-10-16
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多