Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Typescript imports failing in Visual Studio 2015

$
0
0

I am trying to create a simple web app using React.js.  I have successfully set up a npm package.json file:

{

"version": "1.0.0",

"name": "asp.net",
"private": true,
  "devDependencies": {
    "react": "15.4.1",
    "react-dom": "15.4.1" 
  }
}

This correctly loads React code to node_modules.  I have a simple tsx file under webroot beginning with:

import React = require("react");
class Square extends React.Component...

No matter what I try as the require argument, I get "Cannot find module react".

My tsconfig.json is:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "jsx": "react",
    "module": "commonjs"
  },
  "exclude": [
    "node_modules"  ]
}

The .tsx file gets transpiled, and the JSX is handled, so it seems like VS is all set up to handle this, but it can't find the react module.

What am I missing?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>