解析JSON时出错 - JSON5数据的第1行第2列的意外EOF。当我运行构建时
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解析JSON时出错 - JSON5数据的第1行第2列的意外EOF。当我运行构建时相关的知识,希望对你有一定的参考价值。
当我在我的npm run build
项目中Vue.js
时,我得到了以下错误:
ERROR in ./src/vendors.js
Module build failed: SyntaxError: /home/ldl/repo/vue_admin_site/.babelrc: Error while parsing JSON - Unexpected EOF at line 1 column 2 of the JSON5 data. Still to read: ""
at error (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:56:25)
at word (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:393:13)
at value (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:493:56)
at Object.parse (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:508:18)
at ConfigChainBuilder.addConfig (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:150:65)
at ConfigChainBuilder.findConfigs (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:96:16)
at buildConfigChain (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:61:13)
at OptionManager.init (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/option-manager.js:354:58)
at File.initOptions (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/home/ldl/repo/vue_admin_site/node_modules/babel-loader/lib/index.js:46:20)
at Object.module.exports (/home/ldl/repo/vue_admin_site/node_modules/babel-loader/lib/index.js:163:20)
ERROR in ./src/main.js
Module build failed: SyntaxError: /home/ldl/repo/vue_admin_site/.babelrc: Error while parsing JSON - Unexpected EOF at line 1 column 2 of the JSON5 data. Still to read: ""
at error (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:56:25)
at word (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:393:13)
at value (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:493:56)
at Object.parse (/home/ldl/repo/vue_admin_site/node_modules/json5/lib/json5.js:508:18)
at ConfigChainBuilder.addConfig (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:150:65)
at ConfigChainBuilder.findConfigs (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:96:16)
at buildConfigChain (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:61:13)
at OptionManager.init (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/options/option-manager.js:354:58)
at File.initOptions (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/home/ldl/repo/vue_admin_site/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/home/ldl/repo/vue_admin_site/node_modules/babel-loader/lib/index.js:46:20)
at Object.module.exports (/home/ldl/repo/vue_admin_site/node_modules/babel-loader/lib/index.js:163:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! iview-admin@1.1.4 build: `webpack --progress --hide-modules --config build/webpack.prod.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the iview-admin@1.1.4 build 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! /home/ldl/.npm/_logs/2018-05-10T23_56_56_191Z-debug.log
如何解决这个问题?
我在我的项目中找到了.babelrc
文件。
/home/ldl/repo/vue_admin_site/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/estraverse/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/esrecurse/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/localforage/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/escope/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/postcss-discard-overridden/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/iview-area/.babelrc
/home/ldl/repo/vue_admin_site/node_modules/mavon-editor/.babelrc
答案
您.babelrc文件似乎以“UTF8”之外的其他编码保存。您可以使用notepad ++更改文件的编码,或从任何项目下载任何现有的.babelrc文件,并根据需要进行更改。
以上是关于解析JSON时出错 - JSON5数据的第1行第2列的意外EOF。当我运行构建时的主要内容,如果未能解决你的问题,请参考以下文章
SyntaxError:JSON.parse:尝试插入 mysql 时 JSON 数据的第 1 行第 1 列出现意外字符
SyntaxError:JSON.parse:JSON 的第 1 行第 2 列出现意外字符
角/弹簧靴|错误:SyntaxError:“JSON.parse:JSON 数据的第 1 行第 1 列出现意外字符”