“$attrs is readonly”,”$listeners is readonly”,”Avoid mutating a prop directly”

I am new to Vue. I am trying to develop a chatting application where friend list will be shown on the left menu and the chat box will be shown at the body. I am loading friend list using an ajax call and routing to chat box based on friend id. Here is the code sample.

<div class="chat-container clearfix" id="chat">
    <div class="people-list" id="people-list">

    <div class="chat">

chat list component will load friend list from the server. Here is my app.js file;


const router = new VueRouter({
  linkActiveClass: "active"

    import ChatComponent from './components/ChatComponent';
    const routes = [
      { path: '/chat/:id/:name', component: ChatComponent , name: 'chat'}
    Vue.component('chatlist-component', require('./components/ChatlistComponent.vue'));

    const app = new Vue({
        el: '#chat',

And Chat list component template code

<li class="clearfix" v-for="user in users">
                <img :src="https://stackoverflow.com/questions/49585845/baseUrl+"/img/default_image.jpeg'" alt="avatar" class="chat-avatar rounded-circle" />
                <router-link class="about" :to="{ name: 'chat', params: { id: user.id, name:user.name }}">
                    <div class="name">{{user.name}}</div>
                    <div class="status">
                        <i class="fa fa-circle online"></i> online


It works fine until I switch to another user. When I click on any router list from chatlist component it works fine but throws following error to console.

app.js:19302 [Vue warn]: $attrs is readonly.

found in

---> <RouterLink>
       <ChatlistComponent> at resources/assets/js/components/ChatlistComponent.vue

app.js:19302 [Vue warn]: $listeners is readonly.

found in

---> <RouterLink>
       <ChatlistComponent> at resources/assets/js/components/ChatlistComponent.vue

app.js:19302 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "to"

Thanks in advance

First, these errors only come out in non-production builds, however they indicate a problem that should be resolved before production release.

Read More:   What is the purpose of "finally" in try/catch/finally

The $attrs, $listeners and other warnings are displayed if there’s more than one instance of Vue loaded. As I understand it, this can happen usually for one these reasons:

  • it is being loaded/packed into the bundle by webpack and also loaded externally (not via webpack)
  • it is being loaded by something you include (e.g. vuetify, vue-test-utils, vue-cli-electron-builder) one way and by your webpack config another way (e.g. absolute vs relative paths, common.js vs esm.js vue files, runtime-only vue vs compiler+runtime vue)

If you click on that line (it was app.js:19302 in your output above) and put a breakpoint where the message is coming out, you can see the list of modules in the stack traceback to see if there’s more than one path to Vue listed. For example, see that the top three modules have a different path below (but are all part of Vue):
enter image description here
If you see Vue showing up in two or more different ways, it demonstrates that more than one instance of Vue is loaded. Vue only supports a single instance, and can produce these error messages if more than one is loaded.

There are several links to issues included above, the Vuetify issue was the one I filed. In that case, Vuetify requires Vue and was loading it differently than I was. Usually the fix is to check your webpack config where Vue is specified (or isn’t) and try to make it match the way the other copy is being included (e.g. absolute vs relative path, or packed vs external).

This error was happening to me because I was using Git submodules in my project and I had the following folders:

  • ./node_modules – this is for the main project. There was vue installed in these node_modules.
  • ./my_git_submodules/vue_design_system/node_modules – design system that provides basic components (also uses vue). Vue was also installed here!!
Read More:   Defining JavaScript variables inside if-statements

So because both:

  • ./node_modules/vue and
  • ./my_git_submodules/vue_design_system/node_modules/vue

existed, running npm run serve (vue-cli-service build underneath) built two instances of Vue. This was
a really nasty issue because it broke reactivity in certain cases
(ie. you click a button and nothing happens – you just get the
$listeners readonly error)

Quick fix:
removing node_modules in the child folder (vue_design_system) and running npm run serve worked for me.

Long term fix:
you’ll probably need to make Webpack ignore nested node_modules folders by adding a rule in vue.config.js

Adding this to vue.config.js, worked for me.

const path = require('path')

module.exports = {
  configureWebpack: {
    externals: {
      vue: 'Vue'

I faced the same problem. For me, as I installed a local module using

yarn add ../somemodule --force

Seems this command will copy the whole module directory include the node_modules sub-directory. That causes the duplication of the same version of “vue” module. And in the browser devtool I can see multiple sources of the module.

For me, the solution is manually to delete the node_modules every time after install the local module.

In my case, I was migrating from a project that didn’t use VueCLI. In that project, I imported vue from a CDN <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>. In my Vue CLI project, I had copied and pasted my whole index.html file to the Public folder. Vue CLI has it’s own way of importing vue so they were clashing. I simply removed the script and the problem was solved.

This can also happen because you are using npm link to use your unpublished vue packages. Basically identical to @walnut_salami explanation.

The fix for this problem is by moving to this way of including unpublished modules.

Looks like as if there are many possible answers.

I added a npm package manually to the node folder and the problem was the missing npm i command. After using the install command, everything worked fine.

In my case, this error arose after module federating my components.
I solved it by sharing vue in the component receiver to the component supplier.

module.exports = { 
   plugins: [
    new ModuleFederationPlugin({
      name: "dashboard",
      remotes: {
        web_common: "[email protected]://localhost:8081/remoteEntry.js"
      shared: {
        vue: { // this solved my issue.
          eager: true,
          singleton: true,
          requiredVersion: deps.vue


The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts