javascript - 无法在 VS 2015 中运行 Angular 2 应用程序
问题描述
我想使用 angular2 在 VS 2015 上创建一个环境。当我输入“npm start”时,我在下面发现了一个错误。我还在类型“npm start”之前使用了“npm cache clean --force”,但发现了同样的错误。似乎我找到了与这个问题类似的答案“ https://stackoverflow.com/questions/43600838/failed-at -the-angular-quickstart1-0-0-build-script-tsc-p-src/43600902#43600902"但在这里我不明白我应该在哪里改变来解决它。
C:\Users\Hp>cd c:\Users\Hp\Desktop\angular\Angular3Demo\Angular3Demo
c:\Users\Hp\Desktop\angular\Angular3Demo\Angular3Demo>npm start
> angular-quickstart@1.0.0 prestart c:\Users\Hp\Desktop\angular\Angular3Demo\Angular3Demo
> npm run build
> angular-quickstart@1.0.0 build c:\Users\Hp\Desktop\angular\Angular3Demo\Angular3Demo
> tsc -p src/
node_modules/@types/node/index.d.ts(20,1): error TS1084: Invalid 'reference' directive syntax.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! angular-quickstart@1.0.0 build: `tsc -p src/`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Hp\AppData\Roaming\npm-cache\_logs\2020-09-25T20_05_32_810Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! angular-quickstart@1.0.0 prestart: `npm run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 prestart script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Hp\AppData\Roaming\npm-cache\_logs\2020-09-25T20_05_32_902Z-debug.log
c:\Users\Hp\Desktop\angular\Angular3Demo\Angular3Demo>
包.json
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./src/**/*.ts -t verbose"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "~4.3.4",
"@angular/compiler": "~4.3.4",
"@angular/core": "~4.3.4",
"@angular/forms": "~4.3.4",
"@angular/http": "~4.3.4",
"@angular/platform-browser": "~4.3.4",
"@angular/platform-browser-dynamic": "~4.3.4",
"@angular/router": "~4.3.4",
"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.8.4"
},
"devDependencies": {
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "~2.1.0",
"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "^6.0.46",
"@types/jasmine": "2.5.36"
},
"repository": {}
}
我是初学者,请帮忙。
解决方案
npm run serve
击中后enter,它对我有用。
推荐阅读
- android - WebView 本地文件在 Android 9.0 中没有加载页面?
- python - 如何修复 SyntaxError:Raspberry Pi 上的无效语法?
- rust - 添加和+之间的区别?
- java - 为什么不会发生死锁
- opencv - 将openCV与openVINO一起使用的正确方法是什么?
- c++ - 泛化一个函数
- node.js - 在 Azure Blockcahin Visual Studio Code 中创建新的 Solidity 项目时如何修复错误?
- react-native-android - 用动态组件反应原生选择器不显示所选值
- css - 角材料:垫子扩展内的表格未与其他表格对齐
- javascript - 如何(或者是否)将 es6 样式和 csj 样式文件放在我正在发布的 NPM 模块中