ts-loader: "Could not load TypeScript. Try installing with `npm install -g typescript`"

I updated to 0.5.2 from 0.5.0 this morning but still seem to be having the same issue although the new error message is less useful for problem identification. After receiving the error message, I updated typescript to the latest nightly build using ‘npm install -g typescript@next’.

Any insights would be appreciated.

Here’s my webpack.config.js:

'use strict';

var webpack = require('webpack');
var WebpackNotifierPlugin = require('webpack-notifier');

module.exports = {
  entry: './server/server.ts',
  output: {
    path: './build/',
    filename: 'server.js'
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new WebpackNotifierPlugin()
  ],
  resolve: {
    extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', '.ts', '.tsx']
  },
  module: {
    loaders: [
      {
        test: /\.jsx$/,
        exclude: ['./node_modules/'],
        loader: 'babel-loader'
      },
      {
        test: /\.ts(x?)$/,
        exclude: ['./node_modules/'],
        loader: 'ts-loader'
      }
    ]
  }
};

And here is the tsconfig.js:

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "target": "ES5",
        "sourceMap": true
    }
}

With 0.5.0, the error message was: ERROR in ./server/server.ts

Module build failed: Error: Cannot find module ‘typescript’ at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at ensureTypeScriptInstance (partial path elided …/node_modules/ts-loader/index.js:69:20) at Object.loader (partial path elided …/node_modules/ts-loader/index.js:228:14)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 24 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@OldrichDlouhy linking through npm link typescript works perfectly, thanks!