TypeError: this.require is not a function
See original GitHub issuewrite demo according to the readme , get exception:
TypeError: this.require is not a function
at VueComponent.mounted (vue-monaco.common.js?70e3:75)
at callHook (vue.esm.js?efeb:2921)
at Object.insert (vue.esm.js?efeb:4158)
at invokeInsertHook (vue.esm.js?efeb:5960)
at Vue.patch [as __patch__] (vue.esm.js?efeb:6179)
at Vue._update (vue.esm.js?efeb:2660)
at Vue.updateComponent (vue.esm.js?efeb:2788)
at Watcher.get (vue.esm.js?efeb:3142)
at new Watcher (vue.esm.js?efeb:3131)
at mountComponent (vue.esm.js?efeb:2795)
demo code:
- App.vue
<script src="../node_modules/monaco-editor-core/min/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: '../node_modules/monaco-editor-core/min/vs'
}
})
</script>
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
2.helloworld.vue
<template>
<monaco-editor
class="editor"
v-model="code"
language="javascript">
</monaco-editor>
</template>
<script>
import MonacoEditor from 'vue-monaco'
export default {
components: {
MonacoEditor
},
data () {
return {
code: 'const noop = () => {}'
}
}
}
</script>
<style>
.editor {
width: 600px;
height: 800px;
}
</style>
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
NodeJs : TypeError: require(...) is not a function - Stack Overflow
I have read that this usually means that requireJS is not getting loaded properly yet I am not aware why or how to...
Read more >TypeError: require(...) is not a function · Issue #12990 - GitHub
When i run npm start , its show error like above. var model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); TypeError: ...
Read more >NodeJs : TypeError: require(...) is not a function - SyntaxFix
I think this means that module.exports in your ./app/routes module is not assigned to be a function so therefore require('./app/routes') ...
Read more >TypeError require(…) is not a function || NodeJs - YouTube
In this video We will solve NodeJs TypeError require(…) is not a function Error Please follow the Video for Solving this Error.
Read more >JavaScript : NodeJs : TypeError: require(...) is not a function
JavaScript : NodeJs : TypeError : require(...) is not a function [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here.
It is probably related that we use webpack to bundle our application. To my understanding webpack is not able to resolve the AMD require statement if we dynamically assign window.require to a property
I forked the project and run a quick test using just require(… instead of this.require and it worked for me. https://github.com/MaChristmann/vue-monaco/commit/da7b97764f46d94b638ec35e1ba8879c49a2a179
@MaChristmann nice, do you have an example package.json, how to integrate your version in a project? If I use it in a project (vue-cli), like this:
I get the following error:
running npm/yarn doesn’t throw any errors