2

I am attempting to integrate webpack into my typescript application. In order to learn webpack I attempted a minimal migration. So I cloned the Angular2 quickstart seed, added a webpack.config.js:

'use strict';
let path = require('path');

module.exports = {
    entry: './app/main.ts',
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: 'awesome-typescript-loader',
                exclude: /node_modules/,
            },
        ]
    },
    output: {
        filename: '/bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    resolve: {
        extensions: [".tsx", ".ts", ".js"]
    },
};

And attempted a build:

PS C:\Users\ltheisen\git\pastdev-test-webpack> .\node_modules\.bin\webpack --display-error-details
Hash: 954fdea72e6d10e35648
Version: webpack 1.14.0
Time: 31ms

ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./app/main.ts in C:\Users\ltheisen\git\pastdev-test-webpack
resolve file
  C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts.tsx doesn't exist
  C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts.ts doesn't exist
  C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts.js doesn't exist
resolve directory
  C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts\package.json doesn't exist (directory description file)
  C:\Users\ltheisen\git\pastdev-test-webpack\app\main.ts is not a directory (directory default file)

From the --display-error-details output, I can see that it check the file with all 3 extensions from resolve.extensions, but not for the file itself. All of the examples I have found use the file with the extension for entry (webpack basic setup, typescript integrating with build tools, ...). If I remove the extension, the webpack build finds the entry file (though I seem to have other problems...).

Anyway, my question is this: am I doing something wrong? Missing something obvious? Or is the documentation wrong?

---- UPDATE ---- It appears it may be something wrong with the npmjs repository. Specifically, the webpack 2 documentation for installation says:

npm install webpack --save-dev

However, npmjs shows shows version 1.14.0 as the current version:

enter image description here

This seems odd because version 2.2.0 was released last week... But i guess the release hasn't yet propagated to npmjs? After updating to webpack 2, this seems to have resolved my problem...

2 Answers 2

1

Webpack 2 has been at pre-release stage until this moment. I cannot say why 2.2.0 isn't tagged accordingly if it is considered unstable, but it was published this way, npm dist-tag ls webpack outputs:

beta: 2.2.0

latest: 1.14.0

Use appropriate semver to install it:

npm install webpack@2 --save-dev
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the info. I just decided to switch to webpack, so had no idea it was just released. Just saw that there was a version 2 and that the documentation said to simply use npm install webpack. I naturally assumed it was going to install version 2... I have since learned better.
1

npm shows last published version, use npm view webpack to find all versions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.