Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  44] [ 2]  / answers: 1 / hits: 6045  / 5 Years ago, sun, july 7, 2019, 12:00:00

could someone help me with this problem: i'm trying to perform npm run production in laravel project(also using webpack) and getting SyntaxError: Unexpected token / in JSON at position 132 (and also how to catch them using vscode).It seems like something wrong trying to convert to JSON but i couldn't find it. Thank you for your help
Here is github repo




https://github.com/hevzy86/vur




cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

F:Projectsjsvuevue-appEp19node_moduleswebpack-clibincli.js:93
throw err;
^

SyntaxError: Unexpected token / in JSON at position 132
at JSON.parse (<anonymous>)
at BabelConfig.fetchBabelRc (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcBabelConfig.js:30:41)
at Function.generate (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcBabelConfig.js:14:35)
at Object.babel (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcconfig.js:121:45)
at JavaScript.webpackRules (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrccomponentsJavaScript.js:76:41)
at ComponentFactory.applyRules (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrccomponentsComponentFactory.js:155:23)
at Mix.listen.rules (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrccomponentsComponentFactory.js:66:48)
at events.(anonymous function).forEach.handler (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcDispatcher.js:34:47)
at Array.forEach (<anonymous>)
at Dispatcher.fire (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcDispatcher.js:34:28)
at Mix.dispatch (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcMix.js:119:25)
at WebpackConfig.buildRules (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcbuilderWebpackConfig.js:83:13)
at WebpackConfig.build (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsrcbuilderWebpackConfig.js:23:14)
at Object.<anonymous> (F:Projectsjsvuevue-appEp19node_moduleslaravel-mixsetupwebpack.config.js:29:38)
at Module._compile (F:Projectsjsvuevue-appEp19node_modulesv8-compile-cachev8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (F:Projectsjsvuevue-appEp19node_modulesv8-compile-cachev8-compile-cache.js:161:20)
at WEBPACK_OPTIONS (F:Projectsjsvuevue-appEp19node_moduleswebpack-clibinutilsconvert-argv.js:116:13)
at requireConfig (F:Projectsjsvuevue-appEp19node_moduleswebpack-clibinutilsconvert-argv.js:118:6)
at F:Projectsjsvuevue-appEp19node_moduleswebpack-clibinutilsconvert-argv.js:125:17
at Array.forEach (<anonymous>)
at module.exports (F:Projectsjsvuevue-appEp19node_moduleswebpack-clibinutilsconvert-argv.js:123:15)
at yargs.parse (F:Projectsjsvuevue-appEp19node_moduleswebpack-clibincli.js:71:45)
at Object.parse (F:Projectsjsvuevue-appEp19node_moduleswebpack-clinode_modulesyargsyargs.js:567:18)
at F:Projectsjsvuevue-appEp19node_moduleswebpack-clibincli.js:49:8
at Object.<anonymous> (F:Projectsjsvuevue-appEp19node_moduleswebpack-clibincli.js:365:3)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersVladAppDataRoamingnpm-cache_logs2019-07-07T07_05_11_119Z-debug.log

More From » json

 Answers
5

It seems the problem occurs when WebPack tries to parse the babel configuration. Looking at your .babelrc from the repository URL you provided, I found



{

presets: [
@babel/preset-env,
@babel/env,
[es2015, {modules:false}]
]
}

// {
// presets: [
// @babel/preset-env,
// @babel/preset-react,
// [es2015, {modules:false}]
// ],
// plugins: [
// transform-class-properties,
// transform-object-rest-spread
// ]
// }


Babel config is a JSON file. The file should only contain a valid JSON object. It seems you don't know that JSON doesn't support comments. So you should remove all the lines starting with '//'. Hope your problems will be gone.



If you want to learn more about comments in JSON see the second answer from here


[#7007] Thursday, July 4, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryanulyssesb

Total Points: 91
Total Questions: 105
Total Answers: 102

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
ryanulyssesb questions
Sat, Mar 20, 21, 00:00, 3 Years ago
Mon, Sep 14, 20, 00:00, 4 Years ago
Mon, Mar 9, 20, 00:00, 4 Years ago
;