14

So I am using version 8.1.0 of Node.Js and when I call npm init to set up a project it goes to version and stays there. I have tried pressing enter or quitting with ^C but nothing happens. I have waited for over an hour and it hasn't progressed at all. Any idea what I should do?

Here is basically what I am seeing: npm init error

Edit: I tried reinstalling and still didn't work; so I uninstalled version 8.1.0 and installed the user recommended one (6.11.0) and it works fine. I am pretty sure it's a bug in version 8.1.0, but it's the one I need.

Edit 2: Oh, I am running this on Windows 10.

Belos
  • 281
  • 1
  • 3
  • 14

6 Answers6

6

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
Zinox
  • 519
  • 9
  • 24
4

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

Arduino_Sentinel
  • 819
  • 11
  • 21
  • It is still giving an issue with `npm version: 5.3.0` `node version: 8.3.0` on mac. – Priyal Aug 11 '17 at 13:38
  • Use the alternatives suggested then. – Arduino_Sentinel Aug 11 '17 at 13:41
  • It didn't prompt with options without me explicitly pressing an enter key. I didn't know that I had to tap enter, My bad! It works now. – Priyal Aug 11 '17 at 13:44
  • Yah! and i just confirmed on the repo that the errors where fixed since the ``8.2.0 release, which makes you the only one having the problem so far. Btw good to know that you figured where you tripped :) . – Arduino_Sentinel Aug 11 '17 at 13:50
1

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

Belos
  • 281
  • 1
  • 3
  • 14
1

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.

Daksh
  • 956
  • 6
  • 19
0

Yes, I also faced this issue, so you can downgrade the node to LTS version.

Currently 6.11 version is LTS.

It would be easier to downgrade, if you have used a nvm (Node Version Manager) for installing node.

Use below NVM commands

nvm install 6.11
nvm use 6.11
Jitendra Pawar
  • 1,285
  • 15
  • 27
0

enter image description here

I'm using Window OS and I turn off controlled folder access. I hope It can resolve this problem!

Duc Babe
  • 139
  • 1
  • 7