无法在项目中本地安装 Babel



我正在按照这里的步骤 https://babeljs.io/setup#installation。

我创建了一个 package.json 文件,然后运行

npm install --save-dev babel-cli

我收到错误:

npm ERR! Darwin 17.7.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-- 
save-dev" "babel-cli"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! file /Users/name/Desktop/Graphs/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! No data, empty input at 1:1
npm ERR! 
npm ERR! ^
npm ERR! File: /Users/name/Desktop/Graphs/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!     /Users/name/Desktop/Graphs/npm-debug.log

我试过了

npm cache clear

npm update

但它仍然不起作用。有什么想法吗?

你的package.json有问题。与其从空白文件开始,不如运行

npm init

package.json文件生成模板。

如果不想回答自定义模板的所有问题,请运行

npm init -y

以生成空白的默认模板。

最新更新