在这里反应新手。如何让 Visual Studio 2017 运行(通过 F5)由create-react-app 创建的 react.js 应用程序?这是我到目前为止所遵循的步骤:
npm install -g create-react-app
create-react-app my-app
- 在带有 Node.js 工具(1.3.41102.00)的 Visual Studio 2016 RC(5.0.26206.0 D15REL)中,我使用“来自现有代码”选项创建了一个 node.js 项目。
- 我将启动文件设置为 src/index.js
- F5
我收到此错误:
Debugger listening on port 5858
H:\dev\XXXXXX\src\index.js:1
(function (exports, require, module, __filename, __dirname) { import React from 'react';
^^^^^^
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.runMain [as _onTimeout] (module.js:429:10)
at Timer.listOnTimeout (timers.js:92:15)
Press any key to continue...
npm start
工作正常。我假设我需要指示 Visual Studio 执行npm start
或复制npm start
正在执行的操作。我敢肯定我不是第一个尝试过这个的人。推荐的解决方案是什么?