在Ubuntu中运行命令npm start时出错

时间:2016-05-05 11:35:53

标签: node.js npm angular

我是angular2的新手,并尝试在ubuntu上设置angularjs2.0项目。我在根目录my angular2 app中安装了npm。但在npm start上,它会出错:

以下是npm-debug.log

中显示的错误
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install' ]
2 info using npm@2.15.0
3 info using node@v0.10.44
4 verbose node symlink /usr/bin/node
5 verbose config Skipping project config: /home/kisuser/.npmrc. (matches userconfig)
6 verbose readDependencies loading dependencies from /home/kisuser/package.json
7 error install Couldn't read dependencies
8 verbose stack Error: ENOENT, open '/home/kisuser/package.json'
9 verbose cwd /home/kisuser/nimbldeck
10 error Linux 3.13.0-83-generic
11 error argv "/usr/bin/node" "/usr/bin/npm" "install"
12 error node v0.10.44
13 error npm  v2.15.0
14 error path /home/kisuser/package.json
15 error code ENOPACKAGEJSON
16 error errno 34
17 error package.json ENOENT, open '/home/kisuser/package.json'
17 error package.json This is most likely not a problem with npm itself.
17 error package.json npm can't find a package.json file in your current directory.
18 verbose exit [ 34, true ]

我在同一目录中也有package.json文件:

{
  "name": "angular2-webpack-starter",
  "version": "3.0.0",
  "description": "An Angular 2 Webpack Starter kit featuring Angular 2 (Router, Http, Forms, Services, Tests, E2E, Coverage), Karma, Protractor, Jasmine, Istanbul, TypeScript, and Webpack by AngularClass",
  "author": "Patrick Stapleton <patrick@angularclass.com>",
  "homepage": "https://github.com/angularclass/angular2-webpack-starter",
  "license": "MIT",
  "scripts": {
    "clean": "npm cache clean && rimraf node_modules doc typings coverage dist",
    "clean:dist": "rimraf dist",
    "preclean:install": "npm run clean",
    "clean:install": "npm set progress=false && npm install",
    "preclean:start": "npm run clean",
    "clean:start": "npm start",
    "watch": "npm run watch:dev",
    "watch:dev": "webpack --watch --progress --profile --colors --display-error-details --display-cached",
    "watch:test": "npm run test -- --auto-watch --no-single-run",
    "watch:prod": "webpack --watch --config webpack.prod.config.js --progress --profile --colors --display-error-details --display-cached",
    "build": "npm run build:dev",
    "prebuild:dev": "npm run clean:dist",
    "build:dev": "webpack --progress --profile --colors --display-error-details --display-cached",
    "prebuild:prod": "npm run clean:dist",
    "build:prod": "webpack --config webpack.prod.config.js --progress --profile --colors --display-error-details --display-cached",
    "server": "npm run server:dev:hmr",
    "server:dev": "webpack-dev-server --inline --progress --profile --colors --watch --display-error-details --display-cached  --content-base src/",
    "server:dev:hmr": "npm run server:dev -- --hot",
    "server:prod": "http-server dist --cors",
    "webdriver:update": "webdriver-manager update",
    "webdriver:start": "webdriver-manager start",
    "lint": "tsconfig-lint",
    "pree2e": "npm run webdriver:update -- --standalone",
    "e2e": "protractor",
    "e2e:live": "protractor --elementExplorer",
    "test": "karma start",
    "ci": "npm run e2e && npm run test",
    "docs": "typedoc --options typedoc.json --exclude **/*.spec.ts ./src/",
    "start": "npm run server",
    "typings-install": "typings install",
    "postinstall": "npm run typings-install",
    "preversion": "npm test",
    "version": "npm run build",
    "postversion": "git push && git push --tags"
  },
  "dependencies": {
    "angular2": "2.0.0-beta.7",
    "angular2-moment": "^0.4.2",
    "clipboard": "^1.5.9",
    "es6-promise": "^3.1.2",
    "es6-shim": "^0.33.3",
    "es7-reflect-metadata": "^1.6.0",
    "jquery": "^2.2.2",
    "ng2-cookies": "^0.1.4",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15"
  },
  "devDependencies": {
    "compression-webpack-plugin": "^0.3.0",
    "copy-webpack-plugin": "^1.1.1",
    "css-loader": "^0.23.1",
    "es6-promise-loader": "^1.0.1",
    "exports-loader": "^0.6.3",
    "expose-loader": "^0.7.1",
    "faker": "^3.0.1",
    "file-loader": "^0.8.5",
    "html-webpack-plugin": "^2.9.0",
    "http-server": "^0.9.0",
    "ie-shim": "^0.1.0",
    "imports-loader": "^0.6.5",
    "istanbul-instrumenter-loader": "^0.2.0",
    "json-loader": "^0.5.4",
    "json-server": "^0.8.8",
    "karma": "^0.13.21",
    "karma-chrome-launcher": "^0.2.2",
    "karma-coverage": "^0.5.3",
    "karma-jasmine": "^0.3.7",
    "karma-mocha-reporter": "^1.1.6",
    "karma-phantomjs-launcher": "^1.0.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "1.7.0",
    "node-sass": "^3.4.2",
    "phantomjs-polyfill": "0.0.1",
    "phantomjs-prebuilt": "^2.1.4",
    "protractor": "^3.1.1",
    "raw-loader": "0.5.1",
    "remap-istanbul": "^0.5.1",
    "rimraf": "^2.5.2",
    "sass-loader": "^3.1.2",
    "source-map-loader": "^0.1.5",
    "style-loader": "^0.13.0",
    "ts-helper": "0.0.1",
    "ts-loader": "^0.8.1",
    "ts-node": "^0.5.5",
    "tsconfig-lint": "^0.6.0",
    "tslint": "^3.3.0",
    "tslint-loader": "^2.1.0",
    "typedoc": "^0.3.12",
    "typescript": "1.8.2",
    "typings": "^0.6.8",
    "url-loader": "^0.5.7",
    "webpack": "^1.12.14",
    "webpack-dev-server": "^1.14.1",
    "webpack-load-plugins": "^0.1.2",
    "webpack-md5-hash": "^0.0.5",
    "webpack-validator": "^1.0.0-beta.4"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/angularclass/angular2-webpack-starter.git"
  },
  "bugs": {
    "url": "https://github.com/angularclass/angular2-webpack-starter/issues"
  },
  "engines": {
    "node": ">= 4.2.1",
    "npm": ">= 3"
  }
}

请告诉我如何解决此问题。 感谢

1 个答案:

答案 0 :(得分:0)

您没有package.json文件以供npm使用。您需要创建一个包含所有依赖项的域。修复/添加package.json到您的根文件夹,你应该没问题。

这是一个简单的package.json:

{
  "name": "myapp",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies":{}
}

更新: 我克隆了这个项目https://github.com/AngularClass/angular2-webpack-starter.git,并且能够安装并启动。该项目的当前版本更先进,就像一个魅力。你怎么试试?