question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] vue-cli3 use monaco-editor with Unexpected token

See original GitHub issue

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

No response

Reproduction Steps

I use monaco-editor and MonacoWebpackPlugin in my vue-cli project,but I can not run it I use version like this “monaco-editor”: “^0.34.0”,“monaco-editor-webpack-plugin”: “^7.0.1”

Actual (Problematic) Behavior

error in ./node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js

Module parse failed: Unexpected token (161360:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | } | var TypeScriptWorker = class {

_ctx; | _extraLibs = /* @PURE */ Object.create(null); | _languageService = createLanguageService(this);

Expected Behavior

No response

Additional Context

vue.config.js `const MonacoWebpackPlugin = require(‘monaco-editor-webpack-plugin’) const path = require(‘path’)

const minify = process.env.NODE_ENV === ‘development’ ? false : { collapseWhitespace: true, removeComments: true, removeRedundantAttributes: true, removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true, useShortDoctype: true, minifyCSS: true, minifyJS: true }

function resolve(dir) { return path.join(__dirname, dir) }

module.exports = { publicPath: process.env.NODE_ENV === ‘production’ ? ‘/form-generator/’ : ‘/’, pages: { index: { entry: ‘examples/views/index/main.js’, template: ‘public/index.html’, filename: ‘index.html’, chunks: [‘chunk-vendors’, ‘chunk-common’, ‘index’], minify } }, devServer: { overlay: false }, productionSourceMap: false, configureWebpack: { resolve: { alias: { ‘@’: resolve(‘./examples’) } }, devtool: ‘source-map’, plugins: [ new MonacoWebpackPlugin({ languages: [‘typescript’,‘javascript’], // configure your languages here features: [‘coreCommands’, ‘find’] }) // Place it here ] }, css: { loaderOptions: { less: { lessOptions: { // modifyVars: { // ‘primary-color’: ‘#1DA57A’, // ‘link-color’: ‘#1DA57A’, // ‘border-radius-base’: ‘2px’ // }, javascriptEnabled: true } } } } } `

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
DavidDiaocommented, Sep 5, 2022

#2903 maybe you can try the solution here if you are using webpack 4

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /monaco-editor[\\/].*\.js$/,
        loader: "babel-loader",
      },
    ],
  },
}

I solved ”no loaders“ problem with it but got another syntax error when using monaco-editor@0.34(works well with 0.33)

0reactions
daidaibgcommented, Sep 6, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected usage loading foreign module for monaco editor ...
When i try to include optimization options in my vue-cli-3 project, which use monaco-editor in some pages, I get the following error in ......
Read more >
Module parse failed: Unexpected token . You may need an ...
Coding example for the question Module parse failed: Unexpected token . You may need an additional loader to handle the result of these...
Read more >
vue 使用monaco-editor Error: Unexpected usage ... - CSDN博客
vue.config.js 配置chainWebpack const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin') module.exports = { // .
Read more >
Uncaught SyntaxError: Unexpected token < error in vue cli 3
beforeResolve((to, from, next) => { if (to.name) { NProgress.start() } next() }) router.afterEach((to, from) => { NProgress.done() }) Vue.use( ...
Read more >
typescript ,使用monaco-editor_u011010407的博客-程序员宅 ...
vue -cli3 , elementui ,typescript ,使用monaco-editor_u011010407的博客-程序员宅基地_uncaught error: unexpected usage ... 上面的代码的确被执行了,并且Monaco给出了 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found