Search code examples
postcssreact-toolbox

Cannot find module precss


I was trying to get react-toolbox to run. Got the error 'Cannot find module precss' but this is the same code I picked up from the site. Am I missing out on something?

postcss.config.js

module.exports = {
    plugins: [
        require('precss'),
        require('autoprefixer')
    ]
}

webpack.config.js

var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
    template: __dirname + '/app/index.html',    
    filename: 'index.html',
    inject: 'body'
});

module.exports = {

    entry: __dirname + '/app/index.js',
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.css$/,
                loaders: [
                    'style-loader',
                    'css-loader?importLoaders=1',
                    'postcss-loader'
                ]
            }

        ]
    },
    output: {
        filename: 'transformed.js',
        path: __dirname+'/build'
    },
    plugins: [HTMLWebpackPluginConfig]
};

Any thoughts?


Solution

  • What does your package.json look like? Have you added precss as a dependency to your project? You always have to make sure that everything you import/use actually exists in the project.

    You can check this by opening your package.json file and checking if it's in the list of dependencies. If it isn't try running:

    npm install --save precss
    

    This will install it in your project and you should be able to run the command again.