作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每当我尝试运行 npm init 并只接受默认值时,在一个基本项目中,我都会收到此错误:
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "init"
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! name field must be a string.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/taylorhuston/Code/projects/Site_49thFloor/npm-debug.log
我在 OSX 上运行。这是 npm-debug.log 的全部内容
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'init' ]
2 info using npm@3.3.6
3 info using node@v5.0.0
4 verbose config Skipping project config: /Users/taylorhuston/.npmrc. (matches userconfig)
5 silly package data undefined
6 info init written successfully
7 verbose stack Error: name field must be a string.
7 verbose stack at Object.module.exports.fixNameField (/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/lib/fixer.js:206:13)
7 verbose stack at /usr/local/lib/node_modules/npm/node_modules/normalize-package-data/lib/normalize.js:32:38
7 verbose stack at Array.forEach (native)
7 verbose stack at normalize (/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/lib/normalize.js:31:15)
7 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:338:5)
7 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5)
7 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:300:12
7 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16
7 verbose stack at tryToString (fs.js:414:3)
7 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12)
8 verbose cwd /Users/taylorhuston/Code/projects/Site_49thFloor
9 error Darwin 15.4.0
10 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "init"
11 error node v5.0.0
12 error npm v3.3.6
13 error name field must be a string.
14 error If you need help, you may report this error at:
14 error <https://github.com/npm/npm/issues>
15 verbose exit [ 1, true ]
最佳答案
我相信您创建的节点项目的“名称”格式为“MyProject”(package.son 中的名称字段)。它应该是像“myproject”或“my-project”这样的小案例。请引用 https://docs.npmjs.com/files/package.json
关于npm 初始化, 'npm ERR! name field must be a string.',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36421035/
我是一名优秀的程序员,十分优秀!