解析JSON时出错-JSON 5数据的第1行第2列出现意外的EOF,当我npm运行构建时

vbopmzt1  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(276)

当我在我的Vue.js项目npm run build,我得到以下错误:

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
tyg4sfes

tyg4sfes1#

您的.babelrc文件似乎是以“UTF8”以外的其他编码保存的。您可以使用记事本++更改文件的编码,或者从任何项目下载任何现有的.babelrc文件,并根据需要进行更改。

相关问题