"Failed to parse json" error while doing "yo angular" - angularjs

I am learning Angular from this tutorial and here is what I have done so far:
I installed Node v0.10.29 successfully on my 64bit Windows 7 machine. After that, while installing yeoman, I got this issue: https://github.com/yeoman/yeoman.io/issues/283
I ignored that issue assuming that its minor and installed generator-angular which was successful. I used cmd as an administrator for all this.
After that, did yo angular and here is what I got:
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>
As you can notice, the first error here is Failed to parse json. Not sure why it is failing.
As per this answer, I did bower install. Nothing was displayed. I assumed it went successful (I checked the version later).
Versions:
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
I tried this multiple times, starting over, still failed. What am I doing wrong here? Can anyone please point me into the right direction?

Just a tip for anyone running into this issue, the error can be the result of incorrect formatting in your package.json. The terminal error in the question says:
npm ERR! Unexpected string
npm ERR! File: C:\Users\Rahul\AppData\Roaming\npm-cache\send\0.1.4\package\packa
ge.json
So look for something similar in your terminal. It might even point to a specific line number(Note: if it does and you see nothing wrong check a line or two up because the error is often on a line before the one logged in the console error). In my case it pointed to a trailing ',' that caused the JSON parse error.
Carefully go through the package.json line by line. If you don't find anything that could be causing the problem then run npm cache clean and npm install again as suggested above. Hope that helps someone!

Related

Unable to install from forked github repo using npm

I want to fork React Data Grid repo on Github, make some changes and install it in my react app.
I have added name, version, and description attributes in repo's package.json
I have tried to install it via
npm install username/repo_url#branch
It does install and build the package but is ignoring the dist and lib folder in node_modules/react-data-grid/packages/*/ and I am unable to import it in my code.
I have tried
1) commenting dist in my app's .gitignore
2) adding files attribute with dist in my app's package.json
Nothing works.
What am I doing wrong?
EDIT
Here is the stack trace after following #Derek Nguyen response
npm install piby180/react-data-grid#piby-current
> react-data-grid#1.0.0 postinstall C:\Users\Leo\Documents\Work\demos\myapp\node_modules\react-data-grid
> lerna bootstrap --no-ci && lerna run build
lerna notice cli v3.15.0
lerna info Bootstrapping 2 packages
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna success Bootstrapped 2 packages
lerna notice cli v3.15.0
lerna info Executing command in 2 packages: "npm run build"
lerna ERR! npm run build exited 1 in 'react-data-grid'
lerna ERR! npm run build stdout:
> react-data-grid#7.0.0-alpha.13 build C:\Users\Leo\Documents\Work\demos\myapp\node_modules\react-data-grid\packages\react-data-grid
> tsc
error TS6053: File 'C:/Users/Leo/Documents/Work/demos/myapp/node_modules/react-data-grid/packages/react-data-grid-addons/src/index.ts' not found.
error TS6053: File 'C:/Users/Leo/Documents/Work/demos/myapp/node_modules/react-data-grid/packages/react-data-grid/src/index.ts' not found.
Found 2 errors.
lerna ERR! npm run build stderr:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-data-grid#7.0.0-alpha.13 build: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-data-grid#7.0.0-alpha.13 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Leo\AppData\Roaming\npm-cache\_logs\2019-07-17T14_35_42_219Z-debug.log
lerna ERR! npm run build exited 1 in 'react-data-grid'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-data-grid#1.0.0 postinstall: `lerna bootstrap --no-ci && lerna run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-data-grid#1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!
The 'postinstall' script in the package runs lerna bootstrap. According to the doc, it will then do the following:
When run, this command will:
npm install all external dependencies of each package.
Symlink together all Lerna packages that are dependencies of each other.
npm run prepublish in all bootstrapped packages (unless --ignore-prepublish is passed).
npm run prepare in all bootstrapped packages.
The packages in /packages don't have a prepare or prepublish script. You should be able to properly build the subpackage by modifying the root package.json's postinstall script:
postinstall": "lerna bootstrap --no-ci && lerna run build",
I think that should properly build the sub packages.

Having errors in installing yeoman

having this error..
I have installed node using brew.
Trying to setup a angular project but by running commands dependencies folders are not getting created and giving this error.
- node-libs-browser node_modules/webpack/node_modules/node-libs-browser
- watchpack node_modules/webpack/node_modules/watchpack
- chokidar node_modules/webpack/node_modules/watchpack/node_modules/chokidar
npm ERR! Darwin 14.1.0
npm ERR! argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "install" "--save-dev" "webpack#^1.4.0"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3
npm ERR! path /Users/temp/Desktop/node_modules/webpack
npm ERR! code ENOTEMPTY
npm ERR! errno -66
npm ERR! syscall rename
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/temp/Desktop/node_modules/webpack' -> '/Users/temp/Desktop/node_modules/.webpack.DELETE'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/temp/Desktop/faltu/npm-debug.log
how to solve this?
Project Setup (yeoman gulp Angular)
Install node (https://nodejs.org/en/)
Update npm
npm install npm -g
Install yo, gulp, and bower
npm install -g yo
npm install -g gulp
npm install -g bower
Install generator-gulp-angular
npm install -g generator-gulp-angular
Create a new project folder and open command line or terminal in that folder.
Run the yo generator to create project structure and answer the questions that follow
yo gulp-angular [app-name]

How to install Blur Admin?

I have been trying to install blur-admin via (git clone https://github.com/akveo/blur-admin.git). But when I install it from git bash as mentioned in the installation guide it shows the following error:
bower ECONFLICT Unable to
find suitable version for angular
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program
Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! blur_admin#1.2.0 postinstall: bower install npm ERR! Exit
status 1 npm ERR! npm ERR! Failed at the blur_admin#1.2.0 postinstall
script 'bower install'.
npm ERR! This is most likely a problem with the blur_admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install
npm ERR! You can get information on how to open an issue for this
project with:
npm ERR! npm bugs blur_admin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm ERR! npm owner ls blur_admin
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\xampp\htdocs\blur-admin\npm-debug.log
The issue is because Bower is not installed in your Windows Machine.
Try to install bower before installing this AngularJs template.
Use the following command to install bower:
npm install -g bower
Also check if Gulp - Task automation tool is install or not.
Use the following command to install the same:
npm install -g gulp
Now use npm install to install the project and its Package Dependencies.
To run the application:
gulp serve
Sorry I got a little bit late.
Did you try to move the /bower_components/ folder from the /client/ directory to your root project directory? That worked for me.
First
npm i -g npm
Then delete everything in node_modules. When those are deleted, cd to your directory and
npm install
Worked for me. If you are on OSX or Linux, use sudo.
If you are on Windows, make sure you're running as administrator.
The issue is from Bower, as Bower is not installed into the system.
First install the bower by following:
npm install -g bower
Then run the app by :
gulp serve

Can't install Angular 1.5 component router

I'm trying to install the Angular 1.5 component router for use in a new project, but having a lot of difficulty. As per https://docs.angularjs.org/guide/component-router, the following should work:
npm install #angular/router --save
Here's what I see:
$ npm install #angular/router --save
npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/JonathanM/.nvm/versions/node/v4.4.2/bin/node" "/Users/JonathanM/.nvm/versions/node/v4.4.2/bin/npm" "install" "#angular/router" "--save"
npm ERR! node v4.4.2
npm ERR! npm v3.8.6
npm ERR! code E400
npm ERR! 400 Bad Request
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/JonathanM/Workspace/my-angular-app/npm-debug.log
With node v4.4.2 and npm v3.8.6.
I feel like I'm on the wrong version of npm or something, because I also can't install angular with the syntax they mention in the docs (npm install#1.5.x angular --save). When I try, I get a generic Usage: npm <command> error, like it doesn't even recognize the command.
Am I doing something wrong? Did the package(s) get pulled/moved? Any help would be appreciated.
As #PeteBD suspected in his comment, I was pointing to a private npm repo. I was able to successfully install the router with:
npm config set registry https://registry.npmjs.org/
npm install #angular/router --save

npm-install throws exception for angular-seed

I am trying to install and configure angular-seed in my webstorm IDE. After creating project and downloading angular-seed i tried to run npm install
command to install all the dependencies like the page says (https://github.com/angular/angular-seed). But i found the following error when trying to run the command. the error is given bellow:
bower angular-route#~1.4.0 ENOGIT git is not installed or not in the PATH
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.5
npm ERR! npm v2.11.2
npm ERR! code ELIFECYCLE
npm ERR! angular-seed#0.0.0 postinstall: `bower install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-seed#0.0.0 postinstall script 'bower install'.
npm ERR! This is most likely a problem with the angular-seed package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-seed
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\User\WebstormProjects\untitled\npm-debug.log
I tried to install bower first by running the command npm install -g bower and then running another command bower install angular but it does not working either. It shows another error:
bower angular#~1.4.0 ENOGIT git is not installed or not in the PATH
Can anyone help me to find the solution of the problem. Please let me know where i have done wrong.
Do you have installed git?
If you run cmd.exe and write
git
what do you see? If is git installed correctly in global path, you see git help.
If git is installed only as Git Bash, you can run bower in Git Bash.
Alternatively you can (re)install git with this option, then will be git available in command promt (global path)

Resources