鍍金池/ 問答/Linux  HTML/ 通過npm init 生成 package.json的問題

通過npm init 生成 package.json的問題

我新建了個項目,用npm init 生成package.json報錯如下

npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "Vue-Q&A": Tags may not have any characters that encodeURICompo
nent encodes.
About to write to Documents/Vue-Q&A/package.json:

{
  "name": "",
  "version": ""
}


Is this ok? (yes)
npm ERR! Callback called more than once.

npm ERR! A complete log of this run can be found in:
npm ERR!    /.npm/_logs/2017-12-18T01_17_15_433Z-debug.log

生成的package.json只有name和version?
請問這是什么情況?如何解決?

回答
編輯回答
九年囚

無效的name,name會成為url的一部分,不能含有url非法字符。把&去掉看看,當(dāng)encodeURIComponent() 函數(shù)把name作為 URI 組件進行編碼時,出現(xiàn)了錯誤!因為encodeURIComponent不會對 ASCII 字母和數(shù)字進行編碼,也不會對這些 ASCII 標點符號進行編碼: - _ . ! ~ * ' ( ) 。其他字符(比如 :;/?:@&=+$,# 這些用于分隔 URI 組件的標點符號),都是由一個或多個十六進制的轉(zhuǎn)義序列替換的。

2018年7月9日 17:58