matt-oconnell / vue-monaco-editor

Monaco Editor Vue Component
MIT License
253 stars 58 forks source link

Unexpected token punc «(», expected punc «:» #4

Closed dalaoque closed 6 years ago

dalaoque commented 7 years ago

I try to build the app (with npm run build), the following error happens: ERROR in static/js/vendor.11abc18390715624e180.js from UglifyJs SyntaxError: Unexpected token punc «(», expected punc «:» [./~/vue-monaco-editor /src/MonacoLoader.js:3,0]

frohikey commented 7 years ago

I got the same error, installing monaco-editor package helped in my case:

npm install vue-monaco-editor
leinue commented 7 years ago

same problem

leinue commented 7 years ago

I found the solutions in the document

By default, monaco-editor is loaded from a cdn asyncronously using require. To use a local copy of monaco-editor with webpack, we need to expose the dependency in our build directory:

npm install copy-webpack-plugin --save-dev Add this to your webpack.config.js:

const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
  plugins: [
    new CopyWebpackPlugin([
      {
        from: 'node_modules/monaco-editor/min/vs',
        to: 'vs',
      }
    ])
  ]
};

Then, specify the build directory path in the srcPath prop. See src/App.vue for an example.

dalaoque commented 6 years ago

i got it!

the reason is when compile code es2016 to es2015

The solution is add your webpack.config.js loaders: [ { test: /\.js$/, loader: 'babel', include: [path.resolve(__dirname, '../src'), /vue-monaco-editor/] } ]