monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Error: Cannot find module 'monaco-editor'

Open IrfanBaqui opened this issue 8 years ago • 3 comments

I've been getting the the error cannot find monaco-editor when I try to use this package (v0.13.1):

Here's my webpack build:

const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

module.exports = {
  mode:'development',
  devtool: 'source-map',
  optimization: {
    splitChunks:{}
  },
  entry: {
    app: './ui/client/index.js'
  },
  context: path.resolve(__dirname),
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].js',
    publicPath: '/dist/'
  },
  plugins: [
    new ExtractTextPlugin('styles.css'),
    new webpack.DefinePlugin({
      "process.env": {
        BROWSER: JSON.stringify(true)
      }
    }),
    new MonacoWebpackPlugin()
  ],
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        include: path.resolve(__dirname),
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
      }
    ]
  }
};

Any idea why? I also tried adding an alias in webpack to consume monaco-editor/esm/vs/editor/editor.api, but the same error still persists.


monaco-editor version: 0.13.1 Browser: N/A OS: MacOSX 10.12.5

IrfanBaqui avatar Jun 17 '18 18:06 IrfanBaqui

@alexandrudima the problem is that in the package.json a module property is defined for esm but there is no main for the old school.

Adding "main": "./dev/vs/editor/editor.main.js" fixes the issue.

nicoabie avatar Dec 30 '18 01:12 nicoabie

See https://github.com/microsoft/monaco-editor/issues/1290#issuecomment-459075707 and https://github.com/Microsoft/monaco-editor/issues/1288#issuecomment-524352892

Enc-EE avatar Aug 23 '19 15:08 Enc-EE

I believe this has been resolved in the meantime because all the webpack samples at https://github.com/microsoft/monaco-editor-samples work for me now.

alexdima avatar Dec 12 '19 21:12 alexdima