solid-ts-webpack icon indicating copy to clipboard operation
solid-ts-webpack copied to clipboard

it gives the module not found error on yarn build && yarn start

Open aashishg opened this issue 3 years ago • 1 comments

Error: Cannot find module 'webpack-cli/bin/config-yargs'
code: 'MODULE_NOT_FOUND',
Require stack:
solid-ts-webpack/node_modules/webpack-dev-server/bin/webpack-dev-server.js

aashishg avatar Jun 02 '22 17:06 aashishg

You can fix with this package.json and webpack.config

{
  "name": "solid-ts-webpack",
  "version": "0.0.1",
  "description": "Really basic Solid webpack build with TS",
  "scripts": {
    "start": "webpack-dev-server",
    "build": "webpack"
  },
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@babel/plugin-proposal-class-properties": "^7.14.5",
    "@babel/plugin-proposal-object-rest-spread": "^7.14.7",
    "@babel/preset-env": "^7.14.7",
    "@babel/preset-typescript": "^7.14.5",
    "babel-loader": "^8.1.0",
    "babel-preset-solid": "^1.0.0",
    "html-webpack-plugin": "5",
    "webpack": "5",
    "webpack-cli": "5",
    "webpack-dev-server": "4"
  },
  "dependencies": {
    "solid-js": "^1.0.0"
  }
}

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

const config = {
  entry: './src/index.tsx',
  output: {
    filename: 'bundle.js',
    path: path.join(__dirname, 'dist')
  },
  mode: 'development',
  resolve: {
    extensions: ['.tsx', '.ts', '.js', '.json']
  },
  module: {
    rules: [
      {
        test: /\.(ts)x?$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            babelrc: false,
            configFile: false,
            presets: ['@babel/preset-env', 'solid', '@babel/preset-typescript'],
            plugins: ['@babel/plugin-syntax-dynamic-import', '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-object-rest-spread'],
          }
        }
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin()
  ]
}

module.exports = config

lmiller1990 avatar Feb 07 '23 00:02 lmiller1990