node.js name 只能包含 URL 友好的字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48107455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
name can only contain URL-friendly characters
提问by isrj5
I was trying to install package.json with npm init to install bootstrap in my folder but i am getting the error.
我试图使用 npm init 安装 package.json 以在我的文件夹中安装引导程序,但出现错误。
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.
我是新手,我无法完全弄清楚我做错了什么。我正在关注一个教程,我将附上其链接以及我的控制台屏幕截图。


回答by Fathima Linsa K
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.
npm init 其实就是创建 package.json 文件,设置项目的特性(和 bootstrap 没有关系)。因此,在字段包名称中,您必须输入项目的名称(您现在已经输入了 npm install bootstrap 命令),或者如果括号中显示的名称足够,您可以直接按 Enter 键。通过设置项目的所有特征来完成 npm init 过程。
As next step, you can do npm install [email protected] --save. It'll work
下一步,您可以执行npm install [email protected] --save. 它会工作
回答by rexblack
Deleting the lock-file and running npm iagain solved the issue for me.
删除锁定文件并npm i再次运行为我解决了这个问题。
回答by s.hesam
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 installagain.
不仅删除主文件夹中的 package-lock.json 还查找(使用此命令find node_modules/ -iname *-lock*)并删除 node_modules 中的所有“-lock”文件,然后npm install再次运行。
回答by TheOikonomist
Just hit enter and cycle through all the options. You don't type in the npm install until after you have finished init.
只需按 Enter 键并循环浏览所有选项。在完成 init 之前,您不要输入 npm install。
回答by Izhar Ul Haque
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
no spaces & no Capital words
没有空格和大写单词
it solved the problem for me
它为我解决了问题
Happy coding
回答by user12768086
Make sure you are typing in the right place, npm initand then hit enter/return a few times until you are at a prompt starting with C:\Usersif you are in Windows.
确保您在正确的位置键入,npm init然后按 Enter/Return 几次,直到出现以 开头的提示(C:\Users如果您在 Windows 中)。

