首页 > 解决方案 > package.json 中的 Angular 启动错误

问题描述

简写:

第一次使用“Angular”时,我遇到一个错误,告诉我没有找到 tsc(最后是 package.json)。

细节:

我是 Angular 的新手,当我从一本书中开始一个示例时 npm start,我的 package.json 文件出现错误。tsc:未找到错误

sh: 1: tsc: not found

npm ERR! blog-app@1.0.0 start: `tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server" `
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the blog-app@1.0.0 start script.
npm ERR! This is most likely a problem with the blog-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server"
npm ERR! You can get their info via:
npm ERR!     npm owner ls blog-app
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.14.62-v7+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! cwd /home/pi/webpages/3914_Zusatzmaterialien/kickstart/hello-angular
npm ERR! node -v v8.11.1
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/webpages/3914_Zusatzmaterialien/kickstart/hello-angular/npm-debug.log
npm ERR! not ok code 0

我应该npm install在该发行版的目录中运行,导致以下错误:

(node:1635) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
npm WARN package.json blog-app@1.0.0 No README data
npm WARN deprecated typings@1.0.4: Typings is deprecated in favor of NPM @types -- see README for more information
npm ERR! Error: Method Not Allowed
npm ERR!     at errorResponse (/usr/share/npm/lib/cache/add-named.js:260:10)
npm ERR!     at /usr/share/npm/lib/cache/add-named.js:203:12
npm ERR!     at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:167:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:135:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 4.14.62-v7+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi/webpages/angulartry
npm ERR! node -v v8.11.1
npm ERR! npm -v 1.4.21
npm ERR! code E405
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/webpages/angulartry/npm-debug.log
npm ERR! not ok code 0

我多次删除它并重新安装它npm install -g typescript

npm install && npm start导致以下错误

(node:1814) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
npm WARN package.json blog-app@1.0.0 No README data
npm WARN deprecated typings@1.0.4: Typings is deprecated in favor of NPM @types -- see README for more information
npm ERR! Error: Method Not Allowed
npm ERR!     at errorResponse (/usr/share/npm/lib/cache/add-named.js:260:10)
npm ERR!     at /usr/share/npm/lib/cache/add-named.js:203:12
npm ERR!     at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:167:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:135:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 4.14.62-v7+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi/webpages/3914_Zusatzmaterialien/kickstart/hello-angular
npm ERR! node -v v8.11.1
npm ERR! npm -v 1.4.21
npm ERR! code E405
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/webpages/3914_Zusatzmaterialien/kickstart/hello-angular/npm-debug.log
npm ERR! not ok code 0

如果我tsc &&从第 11 行 删除"start": "tsc && npm run copy:html && concurrently \"npm run tsc:w\" \"npm run html:watch\" \"live-server\" ",,我会运行以下错误sh: 1: copyfiles: not found

关于系统:

该系统使用 npm version 在带有 Raspbian 的 Raspberry Pi 上运行npm: '1.4.21'。我的 Typescript 版本似乎是 2.2.1。如果这很重要,我可以通过 Putty 控制系统。

package.json 文件:

{
  "name": "blog-app",
  "version": "1.0.0",
  "description": "Blog Applikation",
  "watch": {
    "copy:html": "./app/**/*.html"
  },
  "scripts": {
    "tsc": "./node_modules/.bin/tsc",
    "tsc:w": "./node_modules/.bin/tsc --watch",
    "start": "tsc && npm run copy:html && concurrently \"npm run tsc:w\" \"npm run html:watch\" \"live-server\" ",
    "html:watch": "onchange \"./app/**/*.html\" -v -- npm run copy:html",
    "copy:html": "copyfiles -u 1 ./app/**/*.html dist"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@angular/common": ">=4.0.0-beta <5.0.0",
    "@angular/compiler": ">=4.0.0-beta <5.0.0",
    "@angular/core": ">=4.0.0-beta <5.0.0",
    "@angular/forms": ">=4.0.0-beta <5.0.0",
    "@angular/http": ">=4.0.0-beta <5.0.0",
    "@angular/platform-browser": ">=4.0.0-beta <5.0.0",
    "@angular/platform-browser-dynamic": ">=4.0.0-beta <5.0.0",
    "systemjs": "0.19.27",
    "core-js": "2.4.1",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.1.0",
    "zone.js": "0.8.4",
    "bootstrap": "3.3.6"
  },
  "devDependencies": {
    "canonical-path": "0.0.2",
    "concurrently": "2.2.0",
    "copyfiles": "1.0.0",
    "http-server": "0.9.0",
    "live-server": "1.1.0",
    "lodash": "4.11.1",
    "npm-watch": "0.1.6",
    "onchange": "3.0.2",
    "rimraf": "2.5.2",
    "tslint": "3.7.4",
    "typescript": "2.2.0",
    "typings": "1.0.4"
  },
  "repository": {}
}

标签: javascriptnode.jsangularnpmraspbian

解决方案


好像typescript没有安装成功。你可以试试 :

npm install -g typescript

接着

npm install && npm start

推荐阅读