I'm trying to enable vue-devtools in Google Chrome. But I cannot enable it. I'm using vue.js inside the Laravel application.
My server runs using php artisan serve
command.
I'm trying to enable vue-devtools in Google Chrome. But I cannot enable it. I'm using vue.js inside the Laravel application.
My server runs using php artisan serve
command.
I was seeing the error message in this question's title and this solution worked for me:
Add Vue.config.devtools = true
to the file where you create the Vue instance (main.js
for me).
Note that, as mentioned in this answer, you need to put the Vue.config.devtools = true
line before you create your store in order for the Vuex part of the devtools to work. If you're creating your Vuex store in a separate file (e.g. store.js
), you may need to have the Vue.config.devtools = true
line in both your main.js
file as well as the store.js
file.
Updated Aug 2022
So apparently as @kissu said, the answer below causes the released code to be an unoptimized one. This might be different than what you want if you want to check production code while being able to check Vue Dev Tools.
Just be aware of it. Unless you don't mind checking the released code in an unoptimized bundle, then the following script is fine. If you don't like the Vue.config.devtools
value being static, it might be time to consider env
variables or something similar.
Here's how to setup Environtment Variables in Vue
Alternative answer for Vue CLI 3.x
Besides what @NathanWailes has said, this is an alternative which allows the Dev Tools to be available through scripts
instead of writing it in your main Vue entry (which is usually main.js
or index.js
).
You can do this by simply adding this script to package.json
scripts: {
"start:dev": "vue-cli-service build --mode=development"
}
Explanation
This was because Vue.config.devtools
are set to false
by default in production mode as said by this GitHub Issue. But this has a work around, simply by using --mode=development
flag provided in the documentation.
Then you can run using npm run start:dev
and check the file in your dist/
folder! ;)
start:dev
. Nonetheless, this answer was when I used Vue 2. I haven't been using Vue 3 yet. If you have something to add, feel free to add it. –
Wrapper If your using CDN; make sure your not using a production (minified) build of the library.
Use: https://unpkg.com/[email protected]/dist/vue.js
Instead of: https://unpkg.com/[email protected]/dist/vue.min.js
You might need to do Ctrl+Alt+I
for it to show up the first time. (Source)
vite build --mode development
In order to enable Vue devtools for vite build --mode development
you need this config:
// vite.config.js
import { defineConfig } from 'vite'
export default defineConfig(({ mode }) => ({
...
define: {
__VUE_PROD_DEVTOOLS__: mode !== 'production'
},
}))
You may use the dev version of vue.js. For example get it here: https://unpkg.com/[email protected]
When using Laravel just make sure you run the proper webpack for your environment for development . Running
npm run watch
should build Vue with debug mode on. Using
npm run production
minifies Vue for production. This will save you having to remember to toggle the debug mode when building for production.
For me Installing latest Vue dev tools - link and enabling 'Allow access to file URLs' in extension settings resolved the issue.
make sure you're running a non-production build of Vue.js. https://github.com/vuejs/vue-devtools/issues/62
Just add into vue.config.js:
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
delete package-lock.json, node_modules, run npm i and VueJS Devtool will be working
you could try to set environment variable NODE_ENV to 'development'
(e.g. set NODE_ENV=development
on Windows or export NODE_ENV="development"
under Linux)
before launching Vue dev server.
In my case for Laravel 9 fresh installation, I forgot to run sail npm run dev
.
If you're using Vite you can configure your environment directory via shared options. If you change that and have NODE_ENV
set to production
you'll receive this message when trying to inspect your app.
If you are using the CDN version of Vue, then you need to set the following configuration:
Vue.config.devtools = true;
After running this command, open the browser console and refresh the page. If the Vue DevTools still don't show up, then try clearing the cache in your browser.
© 2022 - 2024 — McMap. All rights reserved.