21

I was trying to install package.json with npm init to install bootstrap in my folder but i am getting the error.

npm install bootstrap@4.0.0-alpha.6 --save

I am new to this i can't exactly figure what i am doing wrong. I was following a tutorial whose link i'll attach along with screenshot of my console.

this the tutorial link

this is the screenshot

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
isrj5
  • 375
  • 1
  • 2
  • 14
  • 3
    I had the same problem. Then I realized that I never finish the npm init properly. – James Marx Jan 28 '19 at 19:49
  • Semi-unrelated but this error is also thrown (still aka nowadays) if a _scoped_ `package` in your `package.json` is missing the apparently mandatory `/`. As in, you'll get this error if your trying to list e.g. `@my-nice-package` as a `dep`/dependency. This should be `@my-nice-package/some-subpackage` since the whole point of having scoped packages is to 'subclass'/'subpackage' so to speak. – Dr1Ku Nov 23 '22 at 12:19

9 Answers9

14

npm init is actually creating the package.json file and setting the characteristics of the project(It has no relation with bootstrap). So, in the field package name, you have to enter the name of your project (you have now entered the npm install bootstrap command) or you can just press enter if the name displayed in bracket is enough. Complete the npm init processs by setting all characteristics of project.

As next step, you can do npm install bootstrap@4.0.0-alpha.6 --save. It'll work

Fathima Linsa K
  • 618
  • 6
  • 14
12

Deleting the lock-file and running npm i again solved the issue for me.

rexblack
  • 151
  • 1
  • 2
5

I was getting the same problem but I changed package-name first name was like:

My Folder Name

I changed it to

my-folder-name

with no spaces & no capital letters. It solved the problem for me. Happy coding

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Izhar Ul Haque
  • 116
  • 1
  • 5
3

Just hit enter and cycle through all the options. You don't type in the npm install until after you have finished init.

0

Not only DELETE package-lock.json in main folder but also find (whit this command find node_modules/ -iname *-lock*) and delete all '-lock' files in node_modules then run npm install again.

S. Hesam
  • 5,266
  • 3
  • 37
  • 59
0

Make sure you are typing in the right place, npm init and then hit enter/return a few times until you are at a prompt starting with C:\Users if you are in Windows.

Iñigo
  • 1,877
  • 7
  • 25
  • 55
0

I also encountered the same problem when installing sass, because I watched some tutorials on YT where they instructed to use Live Sass Compiler, so I had to change some settings for saving the file. Then I uninstalled it, go through the traditional process of

npm init
npm install node-sass --save-dev
npm run compile:sass 

and .....BAMMMM!!!! It worked

Haris Bouchlis
  • 2,366
  • 1
  • 20
  • 35
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 16 '21 at 07:05
0

Press a few enter that will help you get out of npm init. then type the npm install comment. This worked for me.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

I was also facing the same issue while installing the json-server ...but got resolved actually the problem is not with the folder name....so, there is two way to sort this problem one by ---- after npm init press 5-8 times enter or u can directly use (npm init -y) both will work fine Happy coding

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 13 '22 at 12:52