使用 typescript 的 create-react-app 不起作用

create-react-app with typescript not working

我想使用这个工具创建一个 typescript React 应用程序 Microsoft/TypeScript-React-Starter。我已按照 github 页面中的说明进行操作:

1. npm install -g create-react-app

2. create-react-app my-app --scripts-version=react-scripts-ts

3. cd my-app

4. npm start

然后我得到这个错误:

error TS2304: Cannot find name 'process'

我已经卸载了 create-react-app 并重新安装了它。错误仍然存​​在。 顺便说一句,昨天我用同样的工具创建了一个测试程序并且它工作了。 当我 运行 这个测试程序时,它按预期工作。

但是我今天使用该工具创建的任何应用程序都会抛出上述异常。我认为我的安装已损坏。

如有任何帮助,我们将不胜感激。

回到打字稿版本 2.3.4 对我有用。

我用过:

npm install typescript@2.3.4