Babel / browserify抛出“解析JSON时出错 - 意外令牌o”

时间:2016-08-11 21:28:29

标签: reactjs browserify babel babel-core

尝试使用browserify和babel时出现奇怪的错误:

./node_modules/.bin/browserify app/index.js -o bundle.js -t [ babelify --presets [ es2015 react ] ]

给出:

SyntaxError: /.../package.json: Error while parsing JSON - Unexpected token o in JSON at position 1 while parsing file: /.../index.js
    at Object.parse (native)
    at ConfigChainBuilder.addConfig (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:155:65)
    at ConfigChainBuilder.findConfigs (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:107:30)
    at buildConfigChain (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:66:13)
    at OptionManager.init (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/option-manager.js:369:58)
    at File.initOptions (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/index.js:223:65)
    at new File

我为es2015安装了正确的预设并做出反应,但我不知道为什么它会抛出这个错误。奇怪的是,这个命令正在我的生产服务器上运行......

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

这是package.json解析错误,检查我的用户目录中是否有package.json文件,如果存在,则将其删除。