尝试安装 Babel JSX 预编译器时出错
Error while trying to install Babel JSX precompiler
您好,我在尝试预编译我的 JSX 代码时遇到以下错误。我一直在使用它,但发生了一些事情,我无法安装它
npm install babel-preset-es2015 babel-preset-react
显示此错误消息:
npm ERR! Linux 3.13.0-85-generic npm ERR! argv "/usr/bin/nodejs"
"/usr/bin/npm" "install" "babel-preset-es2015" "babel-preset-react"
npm ERR! node v4.4.5 npm ERR! npm v2.15.5 npm ERR! file
/home/name/.npm/babel-plugin-check-es2015-constants/6.8.0/package/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json npm ERR! Unexpected token '\u0000' at
1:1374 npm ERR!
e#readme","_id":"is-finite@1.0.1","_from":"is-finite@>=1.0.0 <2.0.0"}
npm ERR!
^ npm ERR! File:
/home/name/.npm/babel-plugin-check-es2015-constants/6.8.0/package/package.json
npm ERR! Failed to parse package.json data. npm ERR! package.json must
be actual JSON, not just JavaScript. npm ERR! npm ERR! This is not a
bug in npm. npm ERR! Tell the package author to fix their package.json
file. JSON.parse
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/js/npm-debug.log
如何解决这个问题?
如果您想在计算机上全局安装这些模块,请添加 -g
:
npm install -g babel-preset-es2015 babel-preset-react
否则,这意味着你想在本地安装它。确保您在用于启动该命令的根目录中有 package.json
。关注 package rules. Here is an example. Your can try to validate your package.json
on package-json-validator.com
您好,我在尝试预编译我的 JSX 代码时遇到以下错误。我一直在使用它,但发生了一些事情,我无法安装它
npm install babel-preset-es2015 babel-preset-react
显示此错误消息:
npm ERR! Linux 3.13.0-85-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "babel-preset-es2015" "babel-preset-react" npm ERR! node v4.4.5 npm ERR! npm v2.15.5 npm ERR! file /home/name/.npm/babel-plugin-check-es2015-constants/6.8.0/package/package.json npm ERR! code EJSONPARSE
npm ERR! Failed to parse json npm ERR! Unexpected token '\u0000' at 1:1374 npm ERR! e#readme","_id":"is-finite@1.0.1","_from":"is-finite@>=1.0.0 <2.0.0"} npm ERR!
^ npm ERR! File: /home/name/.npm/babel-plugin-check-es2015-constants/6.8.0/package/package.json npm ERR! Failed to parse package.json data. npm ERR! package.json must be actual JSON, not just JavaScript. npm ERR! npm ERR! This is not a bug in npm. npm ERR! Tell the package author to fix their package.json file. JSON.parsenpm ERR! Please include the following file with any support request: npm ERR! /var/www/html/js/npm-debug.log
如何解决这个问题?
如果您想在计算机上全局安装这些模块,请添加 -g
:
npm install -g babel-preset-es2015 babel-preset-react
否则,这意味着你想在本地安装它。确保您在用于启动该命令的根目录中有 package.json
。关注 package rules. Here is an example. Your can try to validate your package.json
on package-json-validator.com