I'm developing a Laravel project with Laravel 5.7 and VueJs 2.6.7 and I've created a messages.js file as in README. But I only need the json translation files so I've created the file like this:
import messages from './messages';
const trans = new Lang({
messages
}, window.locale);
But when I run npm run dev I receive the following error:
ERROR in ./resources/lang/it.json
Module parse failed: Unexpected token m in JSON at position 0 while parsing near 'module.exports = {"A...'
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token m in JSON at position 0 while parsing near 'module.exports = {"A...'
at JSON.parse (<anonymous>)
at parseJson (/home/vagrant/code/node_modules/json-parse-better-errors/index.js:7:17)
at JsonParser.parse (/home/vagrant/code/node_modules/webpack/lib/JsonParser.js:16:16)
at doBuild.err (/home/vagrant/code/node_modules/webpack/lib/NormalModule.js:460:32)
at runLoaders (/home/vagrant/code/node_modules/webpack/lib/NormalModule.js:342:12)
at /home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/home/vagrant/code/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/home/vagrant/code/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
at provider (/home/vagrant/code/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
at /home/vagrant/code/node_modules/graceful-fs/graceful-fs.js:90:16
at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
@ ./resources/js/messages.js 3:10-49
@ ./resources/js/app.js
@ multi ./resources/js/app.js ./resources/sass/app.scss
The strange thing is that when I use the PHP files (like ../../resources/lang/it/messages.php everything works fine and the file is loaded as expected. Anyway the it.json atm is the same file you can find in caouecs/laravel-lang repository (the file is json/it.json)
Tell me if you need more details and thanks in advance for your answers
I'm developing a Laravel project with Laravel 5.7 and VueJs 2.6.7 and I've created a
messages.js
file as in README. But I only need the json translation files so I've created the file like this:In my app.js file:
But when I run
npm run dev
I receive the following error:The strange thing is that when I use the PHP files (like
../../resources/lang/it/messages.php
everything works fine and the file is loaded as expected. Anyway theit.json
atm is the same file you can find in caouecs/laravel-lang repository (the file isjson/it.json
)Tell me if you need more details and thanks in advance for your answers