【问题标题】:Angular2 QuickStart npm start is not working correctlyAngular2 QuickStart npm start 无法正常工作
【发布时间】:2016-03-23 23:10:42
【问题描述】:

我知道 Angular2 测试版刚刚发布,但我无法重现他们官方网站教程 (https://angular.io/guide/quickstart) 中的步骤。也许有人遇到过类似的问题并且知道该怎么做才能解决这个问题?当我尝试使用npm start 命令启动应用程序时,我得到如下输出:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ]
2 info using npm@2.7.4
3 info using node@v0.12.2
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart angular2-quickstart@1.0.0
6 info start angular2-quickstart@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info angular2-quickstart@1.0.0 Failed to exec start script
9 verbose stack Error: angular2-quickstart@1.0.0 start: `concurrent "npm run tsc:w" "npm run lite" `
9 verbose stack Exit status 127
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack     at EventEmitter.emit (events.js:110:17)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:14:12)
9 verbose stack     at ChildProcess.emit (events.js:110:17)
9 verbose stack     at maybeClose (child_process.js:1015:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid angular2-quickstart@1.0.0
11 verbose cwd /Users/tmrovsky/Documents/angular2/angular2-quickstart
12 error Darwin 13.4.0
13 error argv "node" "/usr/local/bin/npm" "start"
14 error node v0.12.2
15 error npm  v2.7.4
16 error code ELIFECYCLE
17 error angular2-quickstart@1.0.0 start: `concurrent "npm run tsc:w" "npm run lite" `
17 error Exit status 127
18 error Failed at the angular2-quickstart@1.0.0 start script 'concurrent "npm run tsc:w" "npm run lite" '.
18 error This is most likely a problem with the angular2-quickstart package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     concurrent "npm run tsc:w" "npm run lite"
18 error You can get their info via:
18 error     npm owner ls angular2-quickstart
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

我有: 打字稿1.7.5版本 节点0.12.2版本

也许有人可以帮助解决问题:)?

package.json:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.0",
    "systemjs": "0.19.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "concurrently": "^1.0.0",
    "lite-server": "^1.3.1",
    "typescript": "^1.7.3"
  }
}

index.html:

<html>

<head>
    <title>Angular 2 QuickStart</title>

    <!-- 1. Load libraries -->
    <script src="node_modules/es6-shim/es6-shim.js"></script>
    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
        System.config({
            packages: {
                app: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            }
        });
        System.import('app/boot')
                .then(null, console.error.bind(console));
    </script>

</head>

<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>

</html>

app.components.ts:

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1>',
})

export class AppComponent {}

boot.js:

import {bootstrap} from 'angular2/platform/browser'
import  {AppComponent} from './app.component'

bootstrap(AppComponent);

【问题讨论】:

  • 你能用你的文件编辑你的帖子吗?
  • 你的文件夹结构是什么? index.html 是在app/ 中还是在它之外?
  • 首先,您的文件 boot.js 必须是 TypeScript 文件,将其重命名为 boot.ts 。我没有看到任何其他似乎有问题的地方...正如 the_critic 所说,您能否给我们您的项目结构。
  • 它是 boot.ts。我在stackoverflow上错误地输入了'js' - 抱歉。索引 html 位于根目录,例如 package.json。它不在 app/ 目录中。
  • 确保你的节点版本是&gt;=4.2.1 &lt;5,并且你的npm版本是&gt;=2.14.7 &lt;3.0,如DEVELOPER guide中指定的那样。我认为您可以使其与节点 5 一起使用,但我不知道如何。

标签: node.js angular npm


【解决方案1】:
  1. 在 devDependencies 中,typescript 是 1.7.3,但您有 1.7.5 修复通用版本。
  2. index.html 中以正确的顺序导入您的js 文件。 有关更多信息,请参阅此存储库https://github.com/pkozlowski-opensource/ng2-play/blob/master/index.html 或在此处参考我的存储库

    https://github.com/MrPardeep/Angular2-DatePicker

index.html

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <script>
        System.config({
                    defaultJSExtensions: true,
                    map: {
                        rxjs: 'node_modules/rxjs'
                    },
                    packages: {
                        rxjs: {
                        defaultExtension: 'js'
                      }
                    }
                });
    </script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/router.dev.js"></script>
    <script src="node_modules/angular2/bundles/http.dev.js"></script>

<script>
    System.import('dist/bootstrap');
</script> 

【讨论】:

  • 感谢您的重播,但这并不能解决我的问题 :)
  • 正如@Eric 所说,检查你的节点版本应该在 4*5 之间,npm 版本应该在 2*3 之间。或发布您的项目结构,它将帮助我找出问题。
  • 谢谢!这对我有用。此链接特别是:github.com/pkozlowski-opensource/ng2-play/blob/master/…
  • 欢迎您 :) 此链接对于在 angular2 beta0.0 中启动非常有用。
【解决方案2】:

为了让npm start 为我运行,我必须确保我已经全局安装了一些 devDependencies。你试过了吗:

  • npm install -g concurrently
  • npm install -g lite-server
  • npm install -g typescript

【讨论】:

  • 但我认为lite-server 是可选的,您也可以使用其他服务
  • 为我工作。 sudo npm update -g &amp;&amp; sudo npm install -g concurrently lite-server typescript.
  • 别忘了卸载本地版本:npm uninstall lite-server
  • 我在使用 Udemy 课程中的 angular2-seed 启动 Web 服务器时遇到了同样的问题。这解决了我的问题。
  • 是的!全局安装 lite-server 并卸载本地包终于在 Vagrant 上为我工作了!非常感谢!
【解决方案3】:

在复制 angular2-quickstart 文件夹(包括 node_modules)以创建 angular2-tour-of-heroes 文件夹后,我遇到了类似的问题。这很奇怪,因为原件编译得很好,但副本不是......

npm run tsc

我能够通过删除 node_modules 文件夹并重新运行 npm install 来解决问题

这让我很惊讶,所以我做了两个文件夹之间的差异...

diff -rw angular2-quickstart/node_modules/ angular2-tour-of-heroes/node_modules/

有很多差异,package.json 文件中有很多“位置”差异,如下所示:-

diff -rw angular2-quickstart/node_modules/yargs/package.json angular2-tour-of-heroes/node_modules/yargs/package.json
5c5
<       "/Users/michael/Tutorials/angular2/angular2-quickstart/node_modules/lite-server"
---
>       "/Users/michael/Tutorials/angular2/angular2-tour-of-heroes/node_modules/lite-server"

...哪种是有道理的,但也有一些是这样的:-

diff -rw angular2-quickstart/node_modules/utf-8-validate/build/gyp-mac-tool angular2-tour-of-heroes/node_modules/utf-8-validate/build/gyp-mac-tool
607c607,608
<       return {k: self._ExpandVariables(data[k], substitutions) for k in data}
---
>       return dict((k, self._ExpandVariables(data[k],
>                                             substitutions)) for k in data)

...我完全不明白。

哦,好吧,希望这会有所帮助。

【讨论】:

    【解决方案4】:

    试试这个:

    1. 安装最新版本的 npm/nodejs 我清除了我的 npm 安装
    2. 之后,安装tsd npm install -g tsd
    3. 然后克隆https://github.com/johnpapa/angular2-tour-of-heroes.git
    4. 最后是npm inpm start

    【讨论】:

      【解决方案5】:

      首先你需要更新 npm、lite-server 和 typescript:

      sudo npm update -g && sudo npm install -g concurrently lite-server typescript
      

      从 Angular 项目目录中删除 node_modules 文件夹(如果存在)。下一次运行:

      npm install
      

      然后解决 ENOSPC 错误:

      echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
      

      最后:

      npm start
      

      这是我的 package.json 文件:

      {
        "name": "reservationsystem",
        "version": "0.0.1",
        "scripts": {
          "tsc": "tsc",
          "tsc:w": "tsc -w",
          "lite": "lite-server",
          "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
        },
        "dependencies": {
          "a2-in-memory-web-api": "~0.1.0",
          "angular2": "2.0.0-beta.3",
          "es6-promise": "^3.0.2",
          "es6-shim": "^0.33.3",
          "reflect-metadata": "0.1.2",
          "rxjs": "5.0.0-beta.0",
          "systemjs": "0.19.17",
          "zone.js": "0.5.11"
        },
        "devDependencies": {
          "concurrently": "^1.0.0",
          "lite-server": "^2.0.1",
          "typescript": "^1.7.5"
        }
      }

      【讨论】:

      • 我投了赞成票,因为这解决了我的问题。但是我很想了解如何将 fs.inotify.max_user_watches 添加到 /etc/sysctl 修复它。
      • 看来观察者需要更多内存,这提供了。
      • 我发现当我首先删除模块时它似乎工作得更好 -- rm -r node_modules/。无论如何,正如那个人所说,它让我继续前进;我很惊讶fs.inotify.max_user_watches=524288 对我来说似乎太过分了。风中是否有提高理智
      • 值得补充的是,Javascript 快速入门开箱即用。没有巨大的额外费用。而当服务器停止网页stays on screen。打字稿版本只是消失了 404 puff of smoke
      • 这救了我,谢谢。回声 fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
      【解决方案6】:

      这些答案都没有帮助 Ubuntu。最后,我遇到了 John Papa(lite-server 的作者)的解决方案。

      在 Ubuntu 15.10 上,Angular 2 快速入门在终端上运行后立即生效:

      回显 fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

      显然它增加了可用文件监视的数量。

      答案来源:https://github.com/johnpapa/lite-server/issues/9

      【讨论】:

        【解决方案7】:

        只是: npm install -g lite-server

        然后重新启动:npm start

        【讨论】:

          【解决方案8】:

          全局安装包是一种方法,但这会限制您在使用它们的所有项目中使用相同的版本。

          相反,您可以在您的 npm 脚本前加上 ./node_modules/.bin。在您的情况下,package.json 看起来像这样:

          {
            "name": "reservationsystem",
            "version": "0.0.1",
            "scripts": {
              "tsc": "./node_modules/.bin/tsc",
              "tsc:w": "npm run tsc -w",
              "lite": "./node_modules/.bin/lite-server",
              "start": "./node_modules/.bin/concurrent \"npm run tsc:w\" \"npm run lite\" "
            },
            "dependencies": {
              "a2-in-memory-web-api": "~0.1.0",
              "angular2": "2.0.0-beta.3",
              "es6-promise": "^3.0.2",
              "es6-shim": "^0.33.3",
              "reflect-metadata": "0.1.2",
              "rxjs": "5.0.0-beta.0",
              "systemjs": "0.19.17",
              "zone.js": "0.5.11"
            },
            "devDependencies": {
              "concurrently": "^1.0.0",
              "lite-server": "^2.0.1",
              "typescript": "^1.7.5"
            }
          }
          

          我认为 npm 应该在默认情况下在该目录中的每个“脚本”命令前面提供 ./node_modules/.bin,这就是为什么原来的 package.json 看起来是这样的原因。我不确定该功能是否存在于每个 npm 版本中,或者您是否应该指定一些配置设置。值得研究!

          【讨论】:

            【解决方案9】:

            很可能你的 NPM 版本太旧了,我最近在工作的开发人员机器上遇到了这个,输入:

            npm -v
            

            如果它低于当前的稳定版本,您可以从这里https://nodejs.org/en/ 更新您的 Node.js 安装:)

            【讨论】:

              【解决方案10】:

              这对我有用,将/// &lt;reference path="../node_modules/angular2/typings/browser.d.ts" /&gt; 放在引导文件的顶部。

              例如:-

              boot.ts

              /// <reference path="../node_modules/angular2/typings/browser.d.ts" />
              import {bootstrap} from 'angular2/platform/browser'
              import  {AppComponent} from './app.component'
              
              bootstrap(AppComponent);
              

              注意:- 确保您提及正确的参考路径

              【讨论】:

                【解决方案11】:

                将 package.json 中的 start 字段从

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

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

                【讨论】:

                • 他为什么要运行 tsc 两次(tsctsc -w)?
                • 成功了!但为什么?开始对 ng2 感到气馁。
                • 在 Pluralsight Ward Bell 的“play by play angular 2 快速入门”课程中解释了这一点。 “tsc”首先编译代码,因为没有它,在更大的项目中,服务器可能在编译结束之前启动。在这种情况下,服务器会抛出一个错误,表明它不知道该做什么。
                • 2017 年,您在回答中的解决方法暴露了真正的问题,即应用代码中的打字稿存在编译错误。当我修复编译错误时,原始版本在没有您的解决方法的情况下运行良好。
                • 优秀 ... "start": "concurrently \"npm run tsc:w\" \"npm run lite\" " 为我工作...
                【解决方案12】:

                我遇到了同样的问题,我们都忘记在此处包含组件上的“s”:

                import  {AppComponent} from './app.component'
                

                应该是:

                boot.js:

                import {bootstrap} from 'angular2/platform/browser'
                import  {AppComponent} from './app.components'
                
                bootstrap(AppComponent);
                

                【讨论】:

                • 这不是真的,按照例子,app.component上应该没有's'
                【解决方案13】:

                我在 OS X 上遇到了同样的错误(node v6.2.0 和 npm v3.9.3 与 homebrew 一起安装)并且以上任何一个都没有解决。我必须为同时运行的命令添加完整路径。

                在 package.json 中,我改变了这个:

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

                到这里:

                "start": "tsc && concurrently \"/Users/kyen/.node/bin/npm run tsc:w\" \"/Users/kyen/.node/bin/npm run lite\" ",
                

                当然,您需要根据节点全局二进制文件的存储位置更新正确的路径。请注意,我不需要将路径添加到第一个 tsc 命令。似乎只需要同时指定完整路径。

                【讨论】:

                  【解决方案14】:

                  我遇到了同样的问题。但是,以上答案对我来说都不是正确的解决方案。事实证明,这更多是由于我的开发环境而不是任何版本的事物。

                  因为我使用了 Visual Studio Code,所以我在 VSC 中设置了一个构建任务来编译 TypeScript 作为观察者。这就是问题所在。 VSC 已经为 TSC 启动了 NPM 任务,因此在执行教程的“启动”脚本时,VSC 仍在运行 tsc -w 时遇到了问题。

                  我在 VSC 中停止了任务并重新运行了“启动”脚本,它运行良好。

                  解决方案 A:停止和 npm 启动

                  • VSC 命令>任务:终止正在运行的任务
                  • 终端 $npm start

                  之后,为了让所有东西一起工作,我将启动脚本更改为仅启动服务器而不实际启动 TSC。

                  解决方案 B:更改 npm 启动脚本

                  • 替换

                    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "

                  • "start": "npm run lite"

                  解决方案 C:只需运行 lite 服务器命令

                  `npm run lite`
                  

                  【讨论】:

                    【解决方案15】:

                    我遇到了同样的错误。经过大量搜索,我终于找到了这个:Angular2 application install & run via package.json。 然后我尝试替换

                    "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" },

                    "scripts": { "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ", "lite": "lite-server", "postinstall": "typings install", "tsc": "tsc", "tsc:w": "tsc -w", "typings": "typings" },

                    希望对遇到同样错误的人有所帮助。

                    PS:我的错误和Tomasz不一样,就是我的npm版本是3.7.3,node版本是5.9.1。

                    【讨论】:

                      【解决方案16】:

                      卸载所有现有的节点包。 更新 node 和 npm。正如文档中给出的那样,至少 node v5.x.x 和 npm 3.x.x 否则会导致错误。

                      npm clean。 然后做npm installnpm start

                      这为我解决了这个问题。

                      【讨论】:

                      【解决方案17】:

                      如果你使用代理可能会导致这个错误:

                      1. npm config set proxy http://username:pass@proxy:port

                      2. npm config set https-proxy http://username:pass@proxy:port

                      3. 在您的应用程序文件夹中创建一个名为 .typingsrc 的文件,其中包括:

                        • proxy =(第 1 步的值)
                        • https-proxy =(第 1 步的值)
                      4. 运行npm cache clean

                      5. 运行npm install
                      6. 运行npm typings install
                      7. 运行npm start

                      然后就可以了

                      【讨论】:

                      • 不,仍然得到:错误 TS5023:未知的编译器选项“moduleResolution”。
                      【解决方案18】:

                      tsconfig.json中添加以下部分:

                      "compilerOptions": {
                      "target": "es5",
                      "module": "system",
                      "moduleResolution": "node",
                      "sourceMap": true,
                      "emitDecoratorMetadata": true,
                      "experimentalDecorators": true,
                      "removeComments": false,
                      "noImplicitAny": false
                      }
                      

                      \node_modules\typings\typings.json:

                      "ambientDependencies": {
                        "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim /es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
                      }
                      

                      在这些更改之后,它对我有用。

                      【讨论】:

                        【解决方案19】:

                        我通过以下链接解决了我的快速启动程序问题。

                        Angular 2 QuickStart Live-server error

                        更改Package.json 脚本设置

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

                        到:

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

                        【讨论】:

                          【解决方案20】:

                          我在 Windows 10 上遇到了同样的错误。看起来这是并发 npm 包的问题。我找到了 2 个选项来解决这个错误:

                          • 1.在 2 个单独的 cmd 中运行这两个命令:

                            • 在第一次运行中:npm run tsc:w
                            • 在第二个:npm run lite
                          • 2。更改package.json

                            • 只需将启动选项更改为: "start": "tsc &amp;&amp; npm run tsc:w | npm run lite",

                          【讨论】:

                          • 请注意。在 Linux 上:"start": "tsc &amp;&amp; npm run tsc:w &amp; npm run lite",
                          • 嗯,它对我来说是自动重新编译的。
                          • 我指的是我的第一条评论 :) 在 linux 上它不起作用
                          • 只有这个解决方案对我有用。首先尝试(在 2 个单独的 cmd 中运行这两个命令)。然后在两个 cmds 中停止进程。最后应用第二个(更改 package.json)并单独在一个 cmd 中运行“npm start”。如果我更改了一个文件,localhost:3000 会自动刷新并显示我的更改。非常感谢!
                          【解决方案21】:

                          对于 Ubuntu 16.x 用户,安装最新版本 5.x 解决了我在 ubuntu 中的问题

                          curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
                          sudo apt-get install -y nodejs
                          

                          【讨论】:

                            【解决方案22】:

                            看起来angular2-quickstart 无法启动的方式不止一种。我在 Windows 7 上全新安装节点 6.6.0 / npm 3.10.3 下运行 Angular2 version 2.0.0 时遇到了同样的问题。在我的情况下,运行 npm start 会抛出大量打字稿错误:

                            c:\git\angular2-quickstart>npm start
                            
                            > angular2-quickstart@1.0.0 start c:\git\angular2-quickstart
                            > tsc && concurrently "npm run tsc:w" "npm run lite"
                            
                            node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS2304: Cannot find name 'Set'.
                            node_modules/@angular/common/src/pipes/async_pipe.d.ts(39,38): error TS2304: Cannot find name 'Promise'.
                            (...)
                            

                            angular quickstart issue #63, "typings" not being installed correctly 中讨论了此问题。那张票给出的修复是

                            $ ./node_modules/.bin/typings install
                            

                            这对我有用。 (我还不确定这样做的“正确”方法。)

                            【讨论】:

                              【解决方案23】:

                              在快速入门教程中,我完成了npm start 之前的所有步骤。然后我得到了这个错误。然后我删除了angular-quickstart下的node_modules文件夹并再次运行npm install。现在可以了。

                              【讨论】:

                                【解决方案24】:

                                请确保名称正确,因此将 boot.js 中的 component 更改为 components

                                【讨论】:

                                  【解决方案25】:

                                  转到https://github.com/npm/npm/issues/14075 地址。并尝试 juaniliska 的答案。或许能帮到你。

                                  npm 配置获取注册表

                                  npm 缓存清理

                                  npm 安装

                                  【讨论】:

                                    【解决方案26】:

                                    这是我在尝试了所有这些不同的解决方案数小时后今天解决问题的方法 - (适用于仍在寻找另一种方法的人)。

                                    在您的快速入门目录中打开 2 个 cmd 实例:

                                    窗口 #1:

                                    npm run build:watch
                                    

                                    那么……

                                    窗口 #2:

                                    npm run serve
                                    

                                    然后它将在浏览器中打开并按预期工作

                                    【讨论】:

                                      【解决方案27】:

                                      在我的例子中,我只需要添加一个虚拟的 .ts 文件。所以我创建了一个没有内容的 test.ts 文件并运行 npm start 来解决问题。

                                      【讨论】:

                                        【解决方案28】:

                                        将 package.json 中的起始字段更改为:

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

                                        收件人:

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

                                        真的很有帮助。

                                        【讨论】:

                                          【解决方案29】:

                                          在 package.json 文件中,我删除了包含 "prestart": "npm run build" 的行。这似乎是一个阻塞命令,发生在 (npm) start 之前,因此阻止了其他启动命令。

                                          【讨论】:

                                            【解决方案30】:

                                            此答案与 Jim Cooper 的优秀 Pluralsight 课程“Angular 2 Fundamentals”有关。

                                            如果您像我一样在 Windows 10 机器上开始运行命令 npm start 时遇到问题,那么我建议如下:

                                            以管理员身份启动 git bash(按照视频中的步骤操作) 导航到项目目录 (ng2-fundamentals),然后键入以下命令:

                                            npm config get registry
                                            
                                            npm cache clean
                                            
                                            npm install
                                            

                                            安装完成后,您需要修改 node_modules 文件夹内 spawn-default-shell 模块中的 get-shell.js 文件,如下所示:

                                            更改以下内容:

                                            const DETECT_SH_REGEX = /sh$/;
                                            

                                            到这里:

                                            const DETECT_SH_REGEX = /sh/;
                                            

                                            注意从 sh 字符串末尾删除的 $(感谢此修复 alfian777 的原作者,他在 github 上发布了解决方案)

                                            保存文件,然后转到您的 git bash 控制台并键入 npm start

                                            您现在应该看不到任何错误,并且 localhost 页面将在您的默认浏览器中启动(或者打开您的浏览器并导航到 http://localhost:8808/)。

                                            【讨论】:

                                              猜你喜欢
                                              • 2017-02-09
                                              • 2018-04-08
                                              • 2020-03-23
                                              • 2017-07-15
                                              • 2019-03-18
                                              • 2017-06-21
                                              • 1970-01-01
                                              • 2017-10-06
                                              • 2023-03-12
                                              相关资源
                                              最近更新 更多