osx 安装gulp问题

安装gulp的时候一直不成功,我说一下我的安装步骤

1、sudo npm install -g gulp 在全局安装gulp

2、用cd命令定位到测试文件夹

3、使用npm init命令在当地安装package.json文件

4、npm install —-save-dev gulp在本地安装gulp,但是就是这一步一直出错

这是package.json文件

{
  "name": "text",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

这是日志文件

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '—-save-dev',
1 verbose cli   'gulp' ]
2 info using npm@2.15.9
3 info using node@v4.6.0
4 verbose install initial load of /Users/JaneSu/Desktop/text/package.json
5 warn package.json text@1.0.0 No description
6 warn package.json text@1.0.0 No repository field.
7 warn package.json text@1.0.0 No README data
8 verbose readDependencies loading dependencies from /Users/JaneSu/Desktop/text/package.json
9 silly cache add args [ '—-save-dev', null ]
10 verbose cache add spec —-save-dev
11 silly cache add args [ 'gulp', null ]
12 verbose cache add spec gulp
13 silly cache add parsed spec Result {
13 silly cache add   raw: '—-save-dev',
13 silly cache add   scope: null,
13 silly cache add   name: null,
13 silly cache add   rawSpec: '—-save-dev',
13 silly cache add   spec: '/Users/JaneSu/Desktop/text/—-save-dev',
13 silly cache add   type: 'local' }
14 silly cache add parsed spec Result {
14 silly cache add   raw: 'gulp',
14 silly cache add   scope: null,
14 silly cache add   name: 'gulp',
14 silly cache add   rawSpec: '',
14 silly cache add   spec: 'latest',
14 silly cache add   type: 'tag' }
15 silly addNamed gulp@latest
16 verbose addNamed "latest" is being treated as a dist-tag for gulp
17 info addNameTag [ 'gulp', 'latest' ]
18 silly mapToRegistry name gulp
19 silly mapToRegistry using default registry
20 silly mapToRegistry registry https://registry.npmjs.org/
21 silly mapToRegistry data Result {
21 silly mapToRegistry   raw: 'gulp',
21 silly mapToRegistry   scope: null,
21 silly mapToRegistry   name: 'gulp',
21 silly mapToRegistry   rawSpec: '',
21 silly mapToRegistry   spec: 'latest',
21 silly mapToRegistry   type: 'tag' }
22 silly mapToRegistry uri https://registry.npmjs.org/gulp
23 verbose addNameTag registry:https://registry.npmjs.org/gulp not in flight; fetching
24 error addLocal Could not install /Users/JaneSu/Desktop/text/—-save-dev
25 verbose request uri https://registry.npmjs.org/gulp
26 verbose request no auth needed
27 info attempt registry request try #1 at 19:47:11
28 verbose request id c298f54071de1819
29 verbose etag W/"58ddcc1a-1d0bc"
30 verbose lastModified Fri, 31 Mar 2017 03:25:14 GMT
31 http request GET https://registry.npmjs.org/gulp
32 info retry will retry, error on last attempt: TypeError: The header content contains invalid characters
33 info attempt registry request try #2 at 19:47:21
34 verbose etag W/"58ddcc1a-1d0bc"
35 verbose lastModified Fri, 31 Mar 2017 03:25:14 GMT
36 http request GET https://registry.npmjs.org/gulp
37 info retry will retry, error on last attempt: TypeError: The header content contains invalid characters
38 info attempt registry request try #3 at 19:48:21
39 verbose etag W/"58ddcc1a-1d0bc"
40 verbose lastModified Fri, 31 Mar 2017 03:25:14 GMT
41 http request GET https://registry.npmjs.org/gulp
42 silly get cb [ 304, undefined ]
43 verbose etag https://registry.npmjs.org/gulp from cache
44 verbose get saving gulp to /Users/JaneSu/.npm/registry.npmjs.org/gulp/.cache.json
45 verbose correctMkdir /Users/JaneSu/.npm correctMkdir not in flight; initializing
46 silly addNameTag next cb for gulp with tag latest
47 silly addNamed gulp@3.9.1
48 verbose addNamed "3.9.1" is a plain semver version for gulp
49 silly cache afterAdd gulp@3.9.1
50 verbose afterAdd /Users/JaneSu/.npm/gulp/3.9.1/package/package.json not in flight; writing
51 verbose correctMkdir /Users/JaneSu/.npm correctMkdir not in flight; initializing
52 verbose afterAdd /Users/JaneSu/.npm/gulp/3.9.1/package/package.json written
53 verbose stack Error: ENOENT: no such file or directory, open '/Users/JaneSu/Desktop/text/—-save-dev'
53 verbose stack     at Error (native)
54 verbose cwd /Users/JaneSu/Desktop/text
55 error Darwin 16.4.0
56 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "—-save-dev" "gulp"
57 error node v4.6.0
58 error npm  v2.15.9
59 error path /Users/JaneSu/Desktop/text/—-save-dev
60 error code ENOENT
61 error errno -2
62 error syscall open
63 error enoent ENOENT: no such file or directory, open '/Users/JaneSu/Desktop/text/—-save-dev'
63 error enoent This is most likely not a problem with npm itself
63 error enoent and is related to npm not being able to find a file.
64 verbose exit [ -2, true ]

这是什么情况啊

阅读 2.7k
1 个回答

经过我的多次尝试,终于安装成功并能正常使用了。

我整理成了一篇教程,http://blog.leanote.com/post/...,希望能帮到别人不要犯同样的错误。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进