尝试在package.json文件中加载节点包时出错

时间:2016-01-09 07:55:15

标签: json node.js package.json

我执行了这个命令来安装包&将其引用放在package.json文件中。

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_mod
ules\\npm\\bin\\npm-cli.js" "install" "gulp" "browserify" "gulp-browserify" "gulp-clean" "
gulp-concat" "gulp-jshint" "gulp-util" "gulp-embedlr" "gulp-livereload" "tiny-lr" "connect
-livereload" "express" "--save-dev"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! file C:\wamp\www\Consult\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: C:\wamp\www\Consult\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!     C:\wamp\www\Consult\npm-debug.log

启动此命令时出现此错误:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'gulp',
1 verbose cli   'browserify',
1 verbose cli   'gulp-browserify',
1 verbose cli   'gulp-clean',
1 verbose cli   'gulp-concat',
1 verbose cli   'gulp-jshint',
1 verbose cli   'gulp-util',
1 verbose cli   'gulp-embedlr',
1 verbose cli   'gulp-livereload',
1 verbose cli   'tiny-lr',
1 verbose cli   'connect-livereload',
1 verbose cli   'express',
1 verbose cli   '--save-dev' ]
2 info using npm@2.5.1
3 info using node@v0.12.0
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose stack Error: Failed to parse json
5 verbose stack Unexpected end of input
5 verbose stack     at parseError (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:378:25)
5 verbose stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:85:51)
5 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:59:33
5 verbose stack     at evalmachine.<anonymous>:336:14
5 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:102:5
5 verbose stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:99:15)
6 verbose cwd C:\wamp\www\Consult
7 error Windows_NT 6.3.9600
8 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "gulp" "browserify" "gulp-browserify" "gulp-clean" "gulp-concat" "gulp-jshint" "gulp-util" "gulp-embedlr" "gulp-livereload" "tiny-lr" "connect-livereload" "express" "--save-dev"
9 error node v0.12.0
10 error npm  v2.5.1
11 error file C:\wamp\www\Consult\package.json
12 error code EJSONPARSE
13 error Failed to parse json
13 error Unexpected end of input
14 error File: C:\wamp\www\Consult\package.json
15 error Failed to parse package.json data.
15 error package.json must be actual JSON, not just JavaScript.
15 error
15 error This is not a bug in npm.
15 error Tell the package author to fix their package.json file. JSON.parse
16 verbose exit [ 1, true ]

我正在使用安装了npm的windows机器。这是我的npm-debug.log文件

    public void calculate(View view) {
    EditText userInput = (EditText) findViewById(R.id.user_input);
    String numString = userInput.getText().toString();
    double num = new Double(numString).doubleValue();
    CheckBox ozCheckBox = (CheckBox)findViewById(R.id.oz);
    boolean ozInput = ozCheckBox.isChecked();
    CheckBox gCheckBox = (CheckBox)findViewById(R.id.g);
    boolean gInput = gCheckBox.isChecked();
    if(ozInput == true) {
        double output = num*28.3495;
    } else {
        double output = num;
    }
    TextView textView = (TextView)findViewById( R.id.output_textview );
    textView.setText( String.valueOf( output ) );
}

2 个答案:

答案 0 :(得分:1)

您似乎在C:\ wamp \ www \ Consult \ package.json中有一个package.json文件。

package.json文件指定npm应安装哪些软件包。

由于文件存在,npm默认使用它,但无法将内容解析为JSON。

您可以修复package.json文件,也可以将其删除并再次运行命令。

我建议您查看本指南:https://docs.npmjs.com/getting-started/using-a-package.json

答案 1 :(得分:0)

13 Failed to parse json
13 error Unexpected end of input
14 error File: C:\wamp\www\Consult\package.json

C:\wamp\www\Consult\package.json文件中存在拼写错误/语法错误。