vs代码找不到模块"@ angular/core"或任何其他模块 [英] vs code cannot find module '@angular/core' or any other modules
问题描述
我的项目是使用[Angular CLI]版本1.2.6生成的.
my project was generated with [Angular CLI] version 1.2.6.
我可以编译项目,并且可以正常工作,但是我总是在vs代码中遇到错误,告诉我 找不到模块'@ angular/core' 找不到模块'@ angular/router' 找不到模块.....
I can compile the project and it works fine, but I always get error in vs code telling me cannot find module '@angular/core' cannot find module '@angular/router' cannot find module .....
我已经附加了tsconfig.json文件的内容 这让我感到非常沮丧,花了2个小时来找出问题所在, 我还卸载并重新安装了vs代码 它不起作用.
I have attached content of my tsconfig.json file this has been really frustrating for me, spending 2 hours to figure out what is wrong, I have also uninstalled and reinstalled the vs code it doesn't work.
这是我的环境规格:
@angular/cli: 1.2.6
node: 6.9.1
os: win32 x64
@angular/animations: 4.3.4
@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/cli: 1.2.6
@angular/compiler-cli: 4.3.4
@angular/language-service: 4.3.4
os:Microsoft vs 10企业版
os:Microsoft vs 10 enterprise
项目根文件夹
.angular-cli.json
.editorconfig
.gitignore
.vscode
e2e
karma.conf.js
node_modules
package.json
protractor.conf.js
README.md
src
tsconfig.json
tslint.json
node_module文件夹
node_module folder
-@angular
--animations
--cli
--common
--compiler
--compiler-cli
--core
---@angular
---bundles
---core.d.ts
---core.metadata.json
---package.json
---public_api.d.ts
---README.md
---src
---testing
---testing.d.ts
---testing.metadata.json
--forms
--http
--language-service
--platform-browser
--platform-browser-dynamic
--router
--tsc-wrapped
@ng-bootstrap
@ngtools
-@types
--jasmine
--jasminewd2
--node
--q
--selenium-webdriver
tsconfig.json:
tsconfig.json :
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
推荐答案
我卸载了已经安装的所有扩展程序,结果发现以下地址的JavaScript和TypeScript IntelliSense扩展程序引起了该问题. https://marketplace.visualstudio.com/items?itemName=sourcegraph.javascript-打字稿
I uninstalled all extension I had already installed, and it turns out JavaScript and TypeScript IntelliSense extension from below address caused the issue. https://marketplace.visualstudio.com/items?itemName=sourcegraph.javascript-typescript
这里的意思是,当您访问该网站时,您会看到一个黄色标签,告诉您该标签处于预览版本,但是当您浏览vs扩展程序时,您看不到该标签.
the point here is when you visit the website you see there is a yellow label, telling you it is in preview release, but when you browse in vs extensions, you don't see that label.
这篇关于vs代码找不到模块"@ angular/core"或任何其他模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!