问题描述
我开始在Angular应用中收到此错误:
I starting getting this error on my Angular app:
,当我尝试将打字稿降级为正确的版本时:
and when I try to downgrade typescript to the right version doing:
npm install -g typescript@2.7.2
表示已更新1个程序包.
npm install -g typescript@2.7.2
it says updated 1 package.
当我使用验证打字稿版本时npm view typescript version
我仍然得到2.8.3
when I verify typescript version using npm view typescript version
I still get 2.8.3
我什至尝试使用npm uninstall -g typescript
但是当我再次验证打字稿版本时npm view typescript version
我仍然得到2.8.3
but when I verify typescript version againnpm view typescript version
I still get 2.8.3
哪些命令可以正确清除打字稿并将其还原到以前的版本(例如2.7.2)?
What are the commands to properly purge and restore typescript to a previous version such as 2.7.2?
我正在运行节点v10.0.0和npm v6.0.1
I'm running node v10.0.0 and npm v6.0.1
当我运行npm list -g typescript
时,我看到正确的版本是2.7.2,但是仍然以某种方式在全球范围内安装了版本2.8.3
When I run npm list -g typescript
I see the correct version coming 2.7.2 but still version 2.8.3 is installed somehow globally
推荐答案
您应该执行npm install typescript@'>=2.7.2 <2.8.0'
.这将安装您的项目所需的正确打字稿.确保在Angular项目中运行此代码.
You should do npm install typescript@'>=2.7.2 <2.8.0'
. This will install the correct typescript your project needs. Make sure you run this inside your Angular project.
在Windows上,应使用双引号而不是单引号,例如:
On Windows, you should use double quotes instead of single quotes, like so:
npm install typescript@">=2.7.2 <2.8.0"
否则,您会得到The system cannot find the file specified.
.
这篇关于Angular编译器需要TypeScript> = 2.7.2和< 2.8.0,但是找到了2.8.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!