npm init not working and getting stuck on version
As the previous answers say, Its a bug on nodejs v 8.1.0
and the solution is to wait for the new upcoming release or downgrading to previous versions.
But,there are some of us who find downgrading kinder annoying and can't wait for that new patched release :)!
So the the simple work around without either of the solution to your nodejs
is by creating the package.json
manually on your project folder.
Below is the frame of the file.
{
"name": "", //name of the app. ex "yourAppName"
"version": "", //dafault is 1.0.0
"description": "", // description of the app
"dependencies": {
"dependencieName": "version"
}, //ex "shelljs": "^0.7.0"
"devDependencies": {}, //same as the above
"scripts": {
"scriptName": "path/to/script"
},
"repository": {
"type": "git", //git is the default
"url": "git+https://github.com/yourUserName/yourRepoName" //link to your repo
},
"keywords": [],
"author": "", //the author, maybe you :)
"license": "", //License type
"bugs": {
"url": "" //ex "https://github.com/yourUserName/yourRepoName/issues"
},
}
NOTE: You should remove the comments (starting with //) because json config files doesn't support comments by default, otherwise see https://www.npmjs.com/package/json-comments on how to enable config.json
comments
According to what I've read about this issue on GitHub, you can work around it by switching to the earlier Node v8.0.0 and npm v5.0.0 release. This is an issue with Node v8.1.0.
The fix for this issue is already in progress and should be implemented in v8.1.1 of Node which releases in a couple of days. Till then, downgrade to the old version and see if that works for you.
Alright, it seems to be a bug in 8.1.0 and will be fixed in Tuesday's release.
https://github.com/nodejs/node/pull/13560#issuecomment-307565172
I am having the same problem. However to by-pass and create the package.json file you can use the -y flag and this creates a file with defaults that you can edit later
$npm init -y