【问题标题】:Angular 2 QuickStart on Linux not workingLinux 上的 Angular 2 快速入门不起作用
【发布时间】:2017-02-23 01:45:12
【问题描述】:

我正在虚拟机 Linux 机器构建上从头开始设置 Angular 2 快速入门教程。作为 5 分钟快速启动的一部分,我已按照所有说明进行操作,但是当我进入“npm start”时,我收到此错误:

/media/sf_testdev/angular-quickstart$ npm start

> angular-quickstart@1.0.0 start /media/sf_testdev/angular-quickstart
> tsc && concurrently "npm run tsc:w" "npm run lite" 

sh: 1: concurrently: not found

npm ERR! Linux 4.4.0-42-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.3
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! angular-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the angular-quickstart@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "npm run tsc:w" "npm run lite" 
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /media/sf_testdev/angular-quickstart/npm-debug.log

这是我当前的 package.json 文件

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.6",
    "@angular/compiler": "2.0.0-rc.6",
    "@angular/compiler-cli": "0.6.0",
    "@angular/core": "2.0.0-rc.6",
    "@angular/forms": "2.0.0-rc.6",
    "@angular/http": "2.0.0-rc.6",
    "@angular/platform-browser": "2.0.0-rc.6",
    "@angular/platform-browser-dynamic": "2.0.0-rc.6",
    "@angular/router": "3.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.6",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.11",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.17",
    "angular2-in-memory-web-api": "0.0.18",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.2",
    "typescript": "^1.8.10",
    "typings":"^1.3.2"
  }
}

我在网上尝试过的任何东西似乎都无法解决。我在这里先向您的帮助表示感谢!

【问题讨论】:

  • 你的机器上安装npm了吗?
  • 是的,我当然安装了 npm
  • 很确定我在节点 6.x 上遇到了这个问题,我不得不降级到 5.x
  • 安装 typescript 并同时全局安装

标签: node.js linux angular npm


【解决方案1】:

似乎错误在于它尝试同时运行命令时

sh: 1: 并发:未找到

你必须先运行npm install 来安装依赖项,然后你会同时运行,一切都应该正常工作。

【讨论】:

  • 并发安装,我已经运行 npm install
  • 我曾想过当有一些遗漏的依赖时,命令“npm start”会自动调用“npm install”。看来我们必须单独运行每个命令,无论如何,先运行“npm install”是一个很好的提醒。谢谢!
  • start 只是你在 package.json 中设置的一个脚本。你可以把任何东西放在那里,即 npm start 可以运行“npm uninstall”。在他的例子中,你查看 package.json 中的脚本,它正在启动 lite 服务器和 typescript 编译器。
【解决方案2】:
  • 这是因为 tsc 命令在代码中发现错误。如果你只在终端执行 tsc 可以看到错误并修复它。

  • 如果你只运行应用程序删除start行中的tsc &&,最后是这样的:

    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\",

    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",

有了它就可以了。

【讨论】:

    【解决方案3】:

    对不起,我没有看到所有的日志,concurrently: not found 是因为没有安装并发模块,删除node_modules 文件夹并执行:

    npm install
    

    或专门同时安装:

    npm install -g concurrently
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-02
      • 1970-01-01
      • 2021-06-06
      • 2023-03-15
      • 2018-11-15
      • 1970-01-01
      • 1970-01-01
      • 2021-01-20
      相关资源
      最近更新 更多