0

there.

I have a strange troubleshoot with my project. Yesterday, it's work fine. All the pages rendered. No problems until I decide to import only the component I'm using from Bootstrap-Vue, because when I built it from production , Webpack said, "the project is to heavy may be the performance could slow down". Then all the freaking project stopped working( if you go to localhost:8080, you will see a blank page without info about what's going on). I went to the documentation of Bootstrap-Vue for more info and found this piece of code and I pasted into vue.config.js:

module.exports = {
configureWebpack: {
  resolve:{
      alias: {
          'bootstrap-vue$' : 'bootstrap-vue/src/index.js'
      }
  },

  module: {
      rules: [
          {
            test: /\.js$/,
            exclude: /node_modules\/(?!bootstrap-vue\/src\/)/,
            use: {
                loader: 'babel-loader',
                options: {
                    presets: ['env']
                }
            }
          }
      ],

      resolve: {
        alias: {
          vue$: 'vue/dist/vue.runtime.esm.js',
          vue$: 'vue/dist/vue.esm.js' 
        }
      }
  }
}

}

I ran again my project and this error rose up:

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /home/juny/AppsWorkspace/twitty-alpha/src/router/index.js: Cannot 
read property 'bindings' of nul

I checked router's "index.js" and nothing abnormal its there. This is the code of 'router/index.js':

import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import About from '../views/About.vue'
import SignUp from '../views/SignUp.vue'
import TwittyUI from '../views/TwittyUI.vue'
import UserProfile from '../views/UserProfile.vue'
import Settings from '../views/Settings.vue'
import Chat from '../views/Chat.vue'
import UserVerified from '../views/userVerified.vue'

Vue.use(VueRouter)

const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
component: About
},
{
path: '/signUp',
name: 'SignUp',
component: SignUp
},
{
path: '/twit',
name: 'TwittyUI',
component: TwittyUI,
},
{
path: '/userProfile',
name: 'UserProfile',
component: UserProfile,
},
{
path: '/settings',
name: 'Settings',
component: Settings,
},
{
path: '/chat',
name: 'Chat',
component: Chat,
},
{
path: '/userVerified',
name: 'UserVerified',
component: UserVerified,
}
]

const router = new VueRouter({
  routes
}) 

export default router

My main.js file:

import '@babel/polyfill'
import 'mutationobserver-shim'
import Vue from 'vue'
import './plugins/bootstrap-vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import { 
 BootstrapVue, 
 IconsPlugin,
 LayoutPlugin,
 BForm,
 BFormInput,
 BButton,
 BCard,
 NavbarPlugin,
 FormTagsPlugin
} from 'bootstrap-vue'

Vue.use(BootstrapVue)
Vue.use(IconsPlugin)
Vue.use(LayoutPlugin)
Vue.use(BForm)
Vue.use(BFormInput)
Vue.use(BButton)
Vue.use(BCard)
Vue.use(NavbarPlugin)
Vue.use(FormTagsPlugin)

Vue.config.productionTip = false

new Vue({
 router,
 render: h => h(App)
}).$mount('#app')

.. and this is my package.json for more deep insight:

 {
   "name": "twitty-alpha",
   "version": "0.1.0",
   "private": true,
   "scripts": {
   "serve": "vue-cli-service serve",
   "build": "vue-cli-service build",
   "test:unit": "vue-cli-service test:unit",
   "test:e2e": "vue-cli-service test:e2e",
   "lint": "vue-cli-service lint"
 },
 "dependencies": {
   "bootstrap-vue": "^2.1.0",
   "core-js": "^3.6.4",
   "firebase": "^7.14.2",
   "idb": "^5.0.2",
   "register-service-worker": "^1.7.1",
   "vue": "^2.6.11",
   "vue-router": "^3.1.6"
 },
 "devDependencies": {
   "@babel/polyfill": "^7.7.0",
   "@vue/cli-plugin-babel": "^4.3.0",
   "@vue/cli-plugin-e2e-cypress": "^4.3.0",
   "@vue/cli-plugin-eslint": "^4.3.0",
   "@vue/cli-plugin-pwa": "^4.3.0",
   "@vue/cli-plugin-router": "^4.3.0",
   "@vue/cli-plugin-unit-jest": "^4.3.0",
   "@vue/cli-service": "^4.3.0",
   "@vue/test-utils": "1.0.0-beta.31",
   "babel-eslint": "^10.1.0",
   "babel-preset-env": "^1.7.0",
   "bootstrap": "^4.3.1",
   "eslint": "^6.7.2",
   "eslint-plugin-vue": "^6.2.2",
   "mutationobserver-shim": "^0.3.3",
   "popper.js": "^1.16.0",
   "portal-vue": "^2.1.6",
   "sass": "^1.19.0",
   "sass-loader": "^8.0.0",
   "vue-cli-plugin-bootstrap-vue": "^0.6.0",
   "vue-template-compiler": "^2.6.11"
  }
}

Excuse Me, for this very long post , but I'm trying to put all relevant things onto table. So , other guys can use it to solve their problems.I don't have any knowledge on Webpack and Babel so may be is something stupid, I guess. But It something that is out of my knowledge. So,happy hunting!! and Let me know what you did.

Anahuaco
  • 1
  • 2

1 Answers1

0

One issue that pops out is that you are using Vue.use(..) for components as well as plugins... this will not work. Also When you Vue.use(BootstrapVue), you are installing all of BootstrapVue (minus the icons). Which is not what you are expecting.

// Register plugins
Vue.use(IconsPlugin)
Vue.use(LayoutPlugin)
Vue.use(NavbarPlugin)
Vue.use(FormTagsPlugin)
// Register components
Vue.component('BForm', BForm)
Vue.component('BFormInput', BFormInput)
Vue.component('BButton', BButton)
Vue.component('BCard', BCard)
Troy Morehouse
  • 5,320
  • 1
  • 27
  • 38
  • I fix it, but the error it's still rose up --> "TypeError: Cannot read property 'bindings' of null "... and pointed to "../router/index.js" – Anahuaco May 08 '20 at 09:39