Can't import json file

I am not able to import a json file. I get the following error message:

Module not found: Error: Can’t resolve ‘json-loader’

I’ve tried both “import filename from ‘@/assets/filename.json’” and “const filename = require(’@/assets/filename.json’)”, but get same error. I can import a js file using the same path.

I’m using webpack-cli@3.1.2, webpack@4.39.3 and vue@2.5.17. Since I am using webpack 4 I should not have to use a loader, so why is it trying to find ‘json-loader’? Is there something specific to using vue with webpack that I’m missing?

I’ve also tried installing json-loader, but then I get a read syntax error.


I had inserted the following:

    test: /\.(json|geojson)$/,
    loader: 'json-loader',

I my build/webpack.base.conf.js while experimenting with vuelayers. Vuelayers did not need it because it can read geojson on its own. I forgot to remove it and it came back a got me on the issue above! Live and learn!