2

非常にシンプルなTypeScriptアプリケーションがあり、webpackを使用してうまくコンパイルできますが、Visual Studioでビルドしようとすると「Build:モジュールが見つかりません」というエラーが表示されます。私は立ち往生して、どんな助けもありがとう。Visual Studioでコンパイルするときにモジュールが見つかりません

package.json:

{ 
 
    "name": "react-router-test", 
 
    "version": "1.0.0", 
 
    "description": "", 
 
    "main": "./dist/bundle.js", 
 
    "scripts": { 
 
    "test": "echo \"Error: no test specified\" && exit 1" 
 
    }, 
 
    "author": "", 
 
    "license": "ISC", 
 
    "dependencies": { 
 
    "react": "^15.4.0", 
 
    "react-dom": "^15.4.0", 
 
    "react-router": "^3.0.0" 
 
    }, 
 
    "devDependencies": { 
 
    "@types/react": "^0.14.49", 
 
    "@types/react-dom": "^0.14.18", 
 
    "@types/react-router": "^2.0.39", 
 
    "babel-cli": "^6.18.0", 
 
    "babel-core": "^6.18.2", 
 
    "babel-loader": "^6.2.7", 
 
    "babel-preset-es2015": "^6.18.0", 
 
    "babel-preset-react": "^6.16.0", 
 
    "ts-loader": "^1.2.1", 
 
    "typescript": "^2.0.10", 
 
    "webpack": "^1.13.3" 
 
    } 
 
}

webpack.config.js:

module.exports = { 
 
    entry: "./src/Index.tsx", 
 
    output: { 
 
     filename: "./dist/bundle.js" 
 
    }, 
 

 
    resolve: { 
 
     // Add '.ts' and '.tsx' as resolvable extensions. 
 
     extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"] 
 
    }, 
 

 
    module: { 
 
     //loaders: [ 
 
     // { test: /\.tsx$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react!ts-loader' } 
 

 
     loaders: [ 
 
      { 
 
       test: /\.ts(x?)$/, 
 
       loader: "babel-loader!ts-loader" 
 
      }, 
 
     ] 
 

 
    }, 
 

 
    devServer: { 
 
     contentBase: ".", 
 
     host: "localhost", 
 
     port: 8081 
 
    }, 
 

 
    externals: { 
 
     "react": "React", 
 
     "react-dom": "ReactDOM" 
 
    }, 
 

 
}

tsconfig.json:

{ 
 
    "compilerOptions": { 
 
    "noImplicitAny": false, 
 
    "noEmitOnError": true, 
 
    "removeComments": false, 
 
    "sourceMap": true, 
 
    "target": "es6", 
 
    "jsx": "preserve", 
 
    "module": "commonjs" 
 
    } 
 
}

Hello.tsx:

import * as React from "react"; 
 

 
interface IHelloProps { compiler: number } 
 

 
export class Hello extends React.Component<IHelloProps, {}> { 
 
    render() { 
 
     return <div > Hell no 2!</div > 
 
    } 
 
}

+0

すべてがうまく見えますchは私に不思議に思う。 npmをインストールしましたか? –

+0

"npm link typescript"を実行した後、 "typing install --global --save dt〜react"を実行すると役立ちますが、その後、webbackからコンパイルするときにnode_modulesの@typeフォルダと常に競合するようですその後、他のパッケージに問題があり、反応ルータは厳密になります。 –

+0

これを試してください。あなたのノードモジュールフォルダを削除してから、あなたのアプリケーションのルートフォルダに移動し、 'npm install'を実行してください....その後、私にフィードバックを与えてください –

答えて

関連する問題