简体   繁体   English

当我尝试运行npm install时出错

[英]Error when I try to run npm install

I'm just trying to do the first angular.js tutorial on the official website. 我只是想在官方网站上做第一个angular.js教程。 When I try to run npm install from my project directory I get the following error. 当我尝试从项目目录运行npm install时,出现以下错误。

在此处输入图片说明

My package.json file is given below. 我的package.json文件如下。

 { "version": "0.0.0", "private": true, "name": "angular-phonecat", "description": "A tutorial application for AngularJS", "repository": "https://github.com/angular/angular-phonecat", "license": "MIT", "devDependencies": { "karma": "^0.12.16", "karma-chrome-launcher": "^0.1.4", "karma-jasmine": "^0.1.5", "protractor": "~1.0.0", "http-server": "^0.6.1", "tmp": "0.0.23", "bower": "^1.3.1", "shelljs": "^0.2.6" }, "scripts": { "postinstall": "bower install", "prestart": "npm install", "start": "http-server -a 0.0.0.0 -p 8000", "pretest": "npm install", "test": "node node_modules/karma/bin/karma start test/karma.conf.js", "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", "preprotractor": "npm run update-webdriver", "protractor": "protractor test/protractor-conf.js", "update-index-async": "node -e \\"require('shelljs/global'); sed('-i', /\\\\/\\\\/@@NG_LOADER_START@@[\\\\s\\\\S]*\\\\/\\\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\\\n' + cat('bower_components/angular-loader/angular-loader.min.js') + '\\\\n//@@NG_LOADER_END@@', 'app/index-async.html');\\"" } } 

Can someone help me to solve this problem. 有人可以帮我解决这个问题。 Thanks. 谢谢。

The messages are warnings, sometimes that just happens, and they often are uneeded anyway. 这些消息是警告,有时只是发生,并且无论如何它们通常都没有被使用。
As long as the main components, Bower, Protractor, Karma etc are working, then I would try just carry on with the tutorial. 只要Bower,Protractor,Karma等主要组件都在工作,那么我将尝试继续本教程。

You can test they are working by running their commands, eg 您可以通过运行命令来测试它们是否正常工作,例如

./node_modules/.bin/bower help 

But

I think one issue I had with npm and running those commands is that they dont just run like the angular tutorial says. 我认为我使用npm并运行这些命令时遇到的一个问题是它们不会像有角度的教程所说的那样运行。
So where the tutorial says, run this: 因此,在本教程说的地方,运行以下命令:

protractor test/protractor-conf.js

You might have to modify the command to this 您可能需要对此修改命令

./node_modules/.bin/protractor test/protractor-conf.js

Same with bower, karma etc 与凉亭,业力等相同

eg 例如

put this in front of the commands 把它放在命令前面

./node_modules./bin

the ./ says run this as a script and the path is so you access the scripts in the node_modules/.bin directories ./表示将其作为脚本运行,路径为,因此您可以访问node_modules/.bin目录中的脚本

Update 更新
If you want to run a karma test: 如果要运行业力测试:
First, make sure you are in the root directory of the project 首先,确保您在项目的根目录

./node_modules/.bin/karma start test/karma.conf.js  --single-run

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM