I've installed the latest version of Visual Studio 2017; one of the install options I chose was to include the node.js support.
I'm not entirely sure what the installer has done, but I have been working on an angular 2 project for several months; the last time I changed the code was over a month ago before installing VS2017.
The code for the app is not a problem (the app itself is currently working fine in its deployed environment on an IIS web server) - the problem appears to be with tsc the typescript compiler; nearly all of the errors are from typescript core libraries, seemingly not recognising built-in typescript types.
The project is based on the angular2 quickstart seed from some time back in November 2016.
Today, when I run npm start I'm seeing the following typescript errors relating the core libraries:
C:\Source\website>npm start
> angular-quickstart@1.0.0 start C:\Source\website
> tsc && concurrently "tsc -w" "lite-server"
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2693: 'Map' only refers to a type, but is being used as a value here.
node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2693: 'Set' only refers to a type, but is being used as a value here.
node_modules/@types/core-js/index.d.ts(47,36): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(350,48): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(351,52): error TS2304: Cannot find name 'PropertyKey'.
.
.
.
(... The list of errors carries on for many other .ts libraries)
I've attempted several solutions already:
This issue on github https://github.com/Microsoft/vscode/issues/21968 suggests two solutions:
Firstly, adding this into tsconfig.json didn't fix the problem:
"compilerOptions": {
...
"types" : [ "node", "jasmine", "core-js" ]
}
Also running these two commands didn't fix the problem either:
npm i -D @types/core-js
npm i -D core-js
Lastly, trying to change the target in tsconfig.json to various different things including es5, es6, es2015 do not fix the problem either.
Here's my original unmodified tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"./node_modules/@types/"
]
},
"compileOnSave": true,
"exclude": [
"node_modules/*",
"**/*-aot.ts"
]
}
And the package.json:
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"docker-build": "docker build -t ng2-quickstart .",
"docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
"pree2e": "npm run webdriver:update",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w",
"webdriver:update": "webdriver-manager update"
},
"keywords": [],
"author": "",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"@angular/common": "~2.1.2",
"@angular/compiler": "~2.1.2",
"@angular/core": "~2.1.2",
"@angular/forms": "~2.1.2",
"@angular/http": "~2.1.2",
"@angular/platform-browser": "~2.1.2",
"@angular/platform-browser-dynamic": "~2.1.2",
"@angular/router": "~3.1.2",
"@angular/upgrade": "~2.1.2",
"angular-in-memory-web-api": "~0.1.13",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"primeng": "^1.1.0",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.40",
"zone.js": "^0.6.26"
},
"devDependencies": {
"@types/core-js": "^0.9.41",
"@types/jasmine": "^2.5.36",
"@types/node": "^6.0.46",
"@types/selenium-webdriver": "^2.53.33",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"core-js": "^2.4.1",
"http-server": "^0.9.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-htmlfile-reporter": "^0.3.4",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "4.0.9",
"rimraf": "^2.5.4",
"tslint": "^3.15.1",
"typescript": "^2.1.4",
"webdriver-manager": "10.2.5"
},
"repository": {}
}
I've tried reinstalling node.js - currently using version 6.10.2 although I've tried 7.0.0 with no success.
I'm running Typescript version 2.1.0
I'm running Windows 10. The path for nodejs is in my System %PATH% environment variable:
c:\Program Files\nodejs\
Here's the full text for the system %PATH% entry:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files (x86)\GitExtensions\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;%APPDATA%;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\nodejs\
Questions:
- Is it possible that a PATH variable has been broken and/or is pointing to the wrong install of node.js?
- Is there anything else other than packages.config which determines the version of
tsc.exe? - Are there any other environment variables or configuration settings which Visual Studio 2017 could possibly have messed with to break this?
- Has Visual Studio 2017 installed an older node.js (or maybe some newer unconfigured nodejs) somewhere else that I can't see in my list of installed programs? would that cause a conflict?
- Is something overriding the
tsc.exepath?
via Ben Cottrell
No comments:
Post a Comment