npm ERR!无效名称:"@ angular/core"遵循Angular 2快速入门时

编程入门 行业动态 更新时间:2024-10-25 16:25:13
本文介绍了npm ERR!无效名称:"@ angular/core"遵循Angular 2快速入门时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试遵循 Angular 2快速入门,第一步是设置环境.我对npm并不完全陌生-我设法安装并试用了Ember,但是仅此而已.

I am trying to follow the Angular 2 Quick Start and one of the first steps is to setup the environment. I am not completely new to npm - I managed to install and try out Ember, but that's about it.

下面是我创建的package.json文件(从上面的链接复制). 当我运行npm install时,这就是我得到的. 快速入门说,我应该不看到任何npm错误!线.

Below is the package.json file I created (copied from the above link). When I run npm install here is what I get. The quick start says I should not see any npm ERR! lines.

npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12 npm WARN angular2-quickstart@1.0.0 No description npm WARN angular2-quickstart@1.0.0 No repository field. npm ERR! Linux 3.13.0-85-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" npm ERR! node v5.10.1 npm ERR! npm v3.8.3 npm ERR! Invalid name: "@angular/core" npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <github/npm/npm/issues> npm ERR! Please include the following file with any support request: npm ERR! /home/john/development/angular/angular2-quickstart/npm-debug.log

其他尝试只会给我更多相同的体验:

additional tries just give me more of the same:

$ npm install npm ERR! Linux 3.13.0-85-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" npm ERR! node v5.10.1 npm ERR! npm v3.8.3 npm ERR! Invalid name: "@angular/router-deprecated" npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <github/npm/npm/issues> npm ERR! Please include the following file with any support request: npm ERR! /home/john/development/angular/angular2-quickstart/npm-debug.log

如果有帮助的话,这里是npm-debug.log的完整回溯:

Here is the full traceback from the npm-debug.log if that helps anyone:

60 verbose stack Error: Invalid name: "@angular/core" 60 verbose stack at ensureValidName (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:302:15) 60 verbose stack at Object.module.exports.fixNameField (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:206:5) 60 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:29:38 60 verbose stack at Array.forEach (native) 60 verbose stack at normalize (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:28:15) 60 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:338:5) 60 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) 60 verbose stack at ReadFileContext.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:284:20) 60 verbose stack at ReadFileContext.callback (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16) 60 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:324:13) 61 verbose cwd /home/john/development/angular/angular2-quickstart 62 error Linux 3.13.0-85-generic 63 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "@angular/core" 64 error node v5.10.1 65 error npm v3.8.3 66 error Invalid name: "@angular/core" 67 error If you need help, you may report this error at: 67 error <github/npm/npm/issues> 68 verbose exit [ 1, true ]

package.json:

package.json:

{ "name": "angular2-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.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "2.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.1", "@angular/upgrade": "2.0.0-rc.1", "systemjs": "0.19.27", "es6-shim": "^0.35.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.6", "zone.js": "^0.6.12", "angular2-in-memory-web-api": "0.0.7", "bootstrap": "^3.3.6" }, "devDependencies": { "concurrently": "^2.0.0", "lite-server": "^2.2.0", "typescript": "^1.8.10", "typings":"^0.8.1" } }

推荐答案

由于我的评论回答了这个问题,因此我将以答复的形式提供给将来访问此页面的人.

Since my comment answered this question I will provide it in the form of an answer for the future people visiting this page.

经过一段时间的谷歌搜索后,我发现有两个页面存在相同的问题; 第1页和第2页.似乎某些版本的NPM中存在错误,因此只需升级到较新版本即可解决此问题:

After a little Googling I found two pages having the same problem; page 1 and page 2. It seems there's a bug in some versions of NPM so simply upgrading to a newer version should fix the problem:

sudo npm install -g npm

降级也可以解决此问题:

Downgrading could also fix the problem:

sudo npm install -g npm@<version here>

希望这会有所帮助

更多推荐

npm ERR!无效名称:"@ angular/core"遵循Angular 2快速入门时

本文发布于:2023-11-04 10:20:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557660.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:入门   名称   快速   npm   ERR

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!