name can only contain URL-friendly characters
Asked Answered
D

10

23

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

npm install [email protected] --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

Devilfish answered 5/1, 2018 at 5:4 Comment(2)
I had the same problem. Then I realized that I never finish the npm init properly.Soprano
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.Ringtail
R
7

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

Roos answered 11/1, 2020 at 6:44 Comment(0)
B
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 [email protected] --save. It'll work

Bostow answered 5/1, 2018 at 9:35 Comment(3)
I tried that but it says "Sorry, name can only contain URL-friendly characters."Devilfish
What did you enter in package name field?Bostow
Hey @SurajKumar! We are Facing a similar problem here. What did you do to fix it?Lindell
C
13

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

Cock answered 25/2, 2019 at 18:6 Comment(0)
R
7

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

Roos answered 11/1, 2020 at 6:44 Comment(0)
O
3

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

Ostracoderm answered 22/9, 2019 at 10:29 Comment(0)
F
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.

Fraternize answered 9/6, 2019 at 5:22 Comment(0)
W
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.

Wellthoughtof answered 23/1, 2020 at 10:31 Comment(0)
S
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

Stairhead answered 16/9, 2021 at 6:45 Comment(1)
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.Thermostatics
F
0

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

Fredia answered 16/5, 2022 at 7:37 Comment(0)
D
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

Doretheadoretta answered 7/10, 2022 at 19:7 Comment(1)
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.Thermostatics
B
0

Check sometimes in your package.json some wrong packagename added with incorrect version which does not exist.

In my case, I was running

  1. npm init
  2. npm i

Caught the same error as below

npm ERR! code EINVALIDPACKAGENAME npm ERR! Invalid package name "https:" of package "https:@*": name can only contain URL-friendly characters.

In package.json dependencies section - "https:": "*" was noticed

Solution: Remove incorrect package-name from the dependencies/devdependencies list.

Buckner answered 4/4 at 19:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.