Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 执行“yo angular”时出现“无法解析json”错误_Angularjs_Yeoman_Yeoman Generator_Yeoman Generator Angular - Fatal编程技术网

Angularjs 执行“yo angular”时出现“无法解析json”错误

Angularjs 执行“yo angular”时出现“无法解析json”错误,angularjs,yeoman,yeoman-generator,yeoman-generator-angular,Angularjs,Yeoman,Yeoman Generator,Yeoman Generator Angular,我从中学习,以下是我迄今为止所做的: 我在64位Windows 7计算机上成功安装了Node v0.10.29。之后,在安装yeoman时,我遇到了以下问题: 我忽略了这个问题,认为它的次要和安装的发电机是成功的。我使用cmd作为所有这些的管理员 在那之后,你知道了吗?下面是我得到的: c:\x-news>yo angular _-----_ | | .--------------------------. |--(o)--| |

我从中学习,以下是我迄今为止所做的:

我在64位Windows 7计算机上成功安装了Node v0.10.29。之后,在安装yeoman时,我遇到了以下问题:

我忽略了这个问题,认为它的次要和安装的发电机是成功的。我使用cmd作为所有这些的管理员

在那之后,你知道了吗?下面是我得到的:

c:\x-news>yo angular

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |    Welcome to Yeoman,    |
   `---------'   |   ladies and gentlemen!  |
    ( _'U`_ )    '--------------------------'
    /___A___\
     |  ~  |
   __'.___.'__
 '   `  |° ' Y `

Out of the box I include Bootstrap and some AngularJS recommended modules.

[?] Would you like to use Sass (with Compass)? No
[?] Would you like to include Bootstrap? Yes
[?] Which modules would you like to include?
   create app\styles\main.css
   create app\index.html
   create bower.json
   create .bowerrc
   create package.json
   create Gruntfile.js
   invoke   angular:common:C:\Users\Rahul\AppData\Roaming\npm\node_modules\gener
ator-angular\app\index.js
   create     .editorconfig
   create     .gitattributes
   create     .jshintrc
   create     .gitignore
   create     test\.jshintrc
   create     app\.buildignore
   create     app\.htaccess
   create     app\404.html
   create     app\favicon.ico
   create     app\robots.txt
   create     app\views\main.html
   create     app\images\yeoman.png
   invoke   angular:main:C:\Users\Rahul\AppData\Roaming\npm\node_modules\generat
or-angular\app\index.js
   create     app\scripts\app.js
   invoke   angular:controller:C:\Users\Rahul\AppData\Roaming\npm\node_modules\g
enerator-angular\app\index.js
   create     app\scripts\controllers\main.js
   create     test\spec\controllers\main.js
   invoke   karma:app


I'm all done. Running bower install & npm install for you to install the require
d dependencies. If this fails, try running the command yourself.


   create     test\karma.conf.js
   create     .travis.yml
npm WARN package.json xnews@0.0.0 No description
npm WARN package.json xnews@0.0.0 No repository field.
npm WARN package.json xnews@0.0.0 No README data
npm WARN package.json xnews@0.0.0 No description
npm WARN package.json xnews@0.0.0 No repository field.
npm WARN package.json xnews@0.0.0 No README data
npm WARN deprecated grunt-ngmin@0.0.3: use grunt-ng-annotate instead
npm WARN deprecated ngmin@0.4.1: use ng-annotate instead
bower cached        git://github.com/angular/bower-angular-scenario.git#1.2.16
bower validate      1.2.16 against git://github.com/angular/bower-angular-scenar
io.git#1.2.16
bower cached        git://github.com/angular/bower-angular.git#1.2.16
bower validate      1.2.16 against git://github.com/angular/bower-angular.git#1.
2.16
bower cached        git://github.com/angular/bower-angular-mocks.git#1.2.16
bower validate      1.2.16 against git://github.com/angular/bower-angular-mocks.
git#1.2.16
bower cached        git://github.com/es-shims/es5-shim.git#3.1.1
bower validate      3.1.1 against git://github.com/es-shims/es5-shim.git#~3.1.0
bower cached        git://github.com/twbs/bootstrap.git#3.2.0
bower validate      3.2.0 against git://github.com/twbs/bootstrap.git#~3.2.0
bower cached        git://github.com/bestiejs/json3.git#3.3.2
bower validate      3.3.2 against git://github.com/bestiejs/json3.git#~3.3.1
npm WARN optional dep failed, continuing fsevents@0.2.0
npm ERR! Failed to parse json
ERR! Unexpected string
npm ERR! File: C:\Users\Rahul\AppData\Roaming\npm-cache\send\0.1.4\package\packa
ge.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! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd c:\x-news
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! file C:\Users\Rahul\AppData\Roaming\npm-cache\send\0.1.4\package\packag
e.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected string
npm ERR! File: C:\Users\Rahul\AppData\Roaming\npm-cache\send\0.1.4\package\packa
ge.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! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "karma-phantomjs-launcher" "k
arma-jasmine" "grunt-karma" "--save-dev"
npm ERR! cwd c:\x-news
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! file C:\Users\Rahul\AppData\Roaming\npm-cache\send\0.1.4\package\packag
e.json
npm ERR! code EJSONPARSE
--


> phantomjs@1.9.7-15 install c:\x-news\node_modules\karma-phantomjs-launcher\nod
e_modules\phantomjs
> node install.js

Download already available at C:\Users\Rahul\AppData\Local\Temp\phantomjs\phanto
mjs-1.9.7-windows.zip
Extracting zip contents
Copying extracted folder C:\Users\Rahul\AppData\Local\Temp\phantomjs\phantomjs-1
.9.7-windows.zip-extract-1406128242405\phantomjs-1.9.7-windows -> c:\x-news\node
_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom
Writing location.js file
Done. Phantomjs binary available at c:\x-news\node_modules\karma-phantomjs-launc
her\node_modules\phantomjs\lib\phantom\phantomjs.exe
bower cached        git://github.com/jquery/jquery.git#2.1.1
bower validate      2.1.1 against git://github.com/jquery/jquery.git#>= 1.9.0
||


> ws@0.4.31 install c:\x-news\node_modules\karma\node_modules\socket.io\node_mod
ules\socket.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

/
c:\x-news\node_modules\karma\node_modules\socket.io\node_modules\socket.io-clien
t\node_modules\ws>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bi
n\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
npm WARN optional dep failed, continuing fsevents@0.2.0
bower install       json3#3.3.2
bower install       es5-shim#3.1.1
bower install       angular-scenario#1.2.16
bower install       angular-mocks#1.2.16
bower install       angular#1.2.16
bower install       bootstrap#3.2.0
bower install       jquery#2.1.1
\-
json3#3.3.2 bower_components\json3

es5-shim#3.1.1 bower_components\es5-shim

angular-scenario#1.2.16 bower_components\angular-scenario
└── angular#1.2.16

angular-mocks#1.2.16 bower_components\angular-mocks
└── angular#1.2.16

angular#1.2.16 bower_components\angular

bootstrap#3.2.0 bower_components\bootstrap
└── jquery#2.1.1

jquery#2.1.1 bower_components\jquery
-\


> jpegtran-bin@0.2.7 postinstall c:\x-news\node_modules\grunt-contrib-imagemin\n
ode_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin
> node index.js

√ pre-build test passed successfully-



> gifsicle@0.1.6 postinstall c:\x-news\node_modules\grunt-contrib-imagemin\node_
modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle
> node index.js

√ pre-build test passed successfully



> optipng-bin@0.3.9 postinstall c:\x-news\node_modules\grunt-contrib-imagemin\no
de_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin
> node index.js

√ pre-build test passed successfully



> pngquant-bin@0.3.1 postinstall c:\x-news\node_modules\grunt-contrib-imagemin\n
ode_modules\imagemin\node_modules\imagemin-pngquant\node_modules\pngquant-bin
> node index.js

√ pre-build test passed successfully
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     c:\x-news\npm-debug.log
npm ERR! not ok code 0
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     c:\x-news\npm-debug.log
npm ERR! not ok code 0
app/index.html modified.

c:\x-news>
正如您所注意到的,这里的第一个错误是未能解析json。不知道为什么会失败

根据,我做了鲍尔安装。什么也没有显示。我以为它成功了,后来我检查了版本

版本:

c:\x-news>node --version
v0.10.29

c:\x-news>bower --version
1.3.8

c:\x-news>grunt --version
grunt-cli v0.1.13
grunt v0.4.5

c:\x-news>yo --version
1.2.0

c:\x-news>npm --version
1.4.14

我尝试了很多次,重新开始,仍然失败。我做错了什么?有人能给我指出正确的方向吗?

对于遇到这个问题的人来说,这个错误可能是由于package.json中的格式不正确造成的。问题中的终端错误是:

npm ERR! Unexpected string
npm ERR! File: C:\Users\Rahul\AppData\Roaming\npm-cache\send\0.1.4\package\packa
ge.json
所以,在你的终端中寻找类似的东西。它甚至可能指向一个特定的行号注意:如果它指向,并且您没有看到任何错误,请检查一行或两行,因为错误通常出现在控制台中记录的错误之前的一行。在我的例子中,它指向一个导致JSON解析错误的尾随字符“”


仔细逐行检查package.json。如果没有找到任何可能导致问题的原因,请按照上述建议运行npm cache clean和npm install。希望这对别人有帮助

错误是说这是无效的json,但它不是。文件下载时可能已损坏。尝试删除您的node_modules文件夹并清除您的npm缓存npm cache clean send然后再次运行npm install为什么要进行向下投票?我张贴额外的信息,以更好地帮助那些试图解决这个问题!