Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

搭建私有库报错error parse json #830

Closed
leekangtaqi opened this issue Feb 17, 2016 · 13 comments
Closed

搭建私有库报错error parse json #830

leekangtaqi opened this issue Feb 17, 2016 · 13 comments

Comments

@leekangtaqi
Copy link

/home/www/test2$ sudo cnpm publish ==> error

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/lib/node_modules/cnpm/node_modules/.bin/npm',
1 verbose cli '--userconfig=/home/dd/.cnpmrc',
1 verbose cli '--disturl=https://npm.taobao.org/mirrors/node',
1 verbose cli '--cache=/home/dd/.cnpm',
1 verbose cli '--registry=http://localhost:7001/',
1 verbose cli '--node-gyp=/usr/local/lib/node_modules/cnpm/node_modules/node-gyp/bin/node-gyp.js',
1 verbose cli 'publish' ]
2 info using [email protected]
3 info using [email protected]
4 verbose publish [ '.' ]
5 silly cache add args [ '.', null ]
6 verbose cache add spec .
7 silly cache add parsed spec Result {
7 silly cache add raw: '.',
7 silly cache add scope: null,
7 silly cache add name: null,
7 silly cache add rawSpec: '.',
7 silly cache add spec: '/home/www/test2',
7 silly cache add type: 'directory' }
8 verbose addLocalDirectory /home/dd/.cnpm/@trillers/test2/1.0.0/package.tgz not in flight; packing
9 verbose correctMkdir /home/dd/.cnpm correctMkdir not in flight; initializing
10 verbose tar pack [ '/home/dd/.cnpm/@trillers/test2/1.0.0/package.tgz',
10 verbose tar pack '/home/www/test2' ]
11 verbose tarball /home/dd/.cnpm/@trillers/test2/1.0.0/package.tgz
12 verbose folder /home/www/test2
13 info prepublish @trillers/[email protected]
14 verbose addLocalTarball adding from inside cache /home/dd/.cnpm/@trillers/test2/1.0.0/package.tgz
15 verbose correctMkdir /home/dd/.cnpm correctMkdir not in flight; initializing
16 silly cache afterAdd @trillers/[email protected]
17 verbose afterAdd /home/dd/.cnpm/@trillers/test2/1.0.0/package/package.json not in flight; writing
18 verbose correctMkdir /home/dd/.cnpm correctMkdir not in flight; initializing
19 verbose afterAdd /home/dd/.cnpm/@trillers/test2/1.0.0/package/package.json written
20 silly publish { name: '@trillers/test2',
20 silly publish version: '1.0.0',
20 silly publish description: '',
20 silly publish main: 'index.js',
20 silly publish scripts: { test: 'echo "Error: no test specified" && exit 1' },
20 silly publish author: '',
20 silly publish license: 'ISC',
20 silly publish dependencies: { co: '^4.6.0' },
20 silly publish readme: 'ERROR: No README data found!',
20 silly publish _id: '@trillers/[email protected]',
20 silly publish _shasum: 'fd272471c0647cb0896d0b23a345ae3629f1d4b2',
20 silly publish _from: '.' }
21 verbose getPublishConfig undefined
22 silly mapToRegistry name @trillers/test2
23 silly mapToRegistry scope (from package name) @trillers
24 verbose mapToRegistry no registry URL found in name for scope @trillers
25 silly mapToRegistry using default registry
26 silly mapToRegistry registry http://localhost:7001/
27 silly mapToRegistry uri http://localhost:7001/@trillers%2ftest2
28 verbose publish registryBase http://localhost:7001/
29 silly publish uploading /home/dd/.cnpm/@trillers/test2/1.0.0/package.tgz
30 verbose request uri http://localhost:7001/@trillers%2ftest2
31 verbose request sending authorization for write operation
32 info attempt registry request try #1 at 9:41:51 PM
33 verbose request id f37da4d4c7fcfcd8
34 http request PUT http://localhost:7001/@trillers%2ftest2
35 http 500 http://localhost:7001/@trillers%2ftest2
36 verbose bad json Internal Server Error
37 error registry error parsing json
38 verbose headers { 'content-type': 'text/plain; charset=utf-8',
38 verbose headers 'content-length': '21',
38 verbose headers date: 'Wed, 17 Feb 2016 02:41:51 GMT',
38 verbose headers connection: 'keep-alive' }
39 info retry will retry, error on last attempt: SyntaxError: Unexpected token I
39 info retry Internal Server Error
40 info attempt registry request try #2 at 9:42:01 PM
41 http request PUT http://localhost:7001/@trillers%2ftest2
42 http 500 http://localhost:7001/@trillers%2ftest2
43 verbose bad json Internal Server Error
44 error registry error parsing json
45 verbose headers { 'content-type': 'text/plain; charset=utf-8',
45 verbose headers 'content-length': '21',
45 verbose headers date: 'Wed, 17 Feb 2016 02:42:01 GMT',
45 verbose headers connection: 'keep-alive' }
46 info retry will retry, error on last attempt: SyntaxError: Unexpected token I
46 info retry Internal Server Error
47 info attempt registry request try #3 at 9:43:01 PM
48 http request PUT http://localhost:7001/@trillers%2ftest2
49 http 500 http://localhost:7001/@trillers%2ftest2
50 verbose bad json Internal Server Error
51 error registry error parsing json
52 verbose headers { 'content-type': 'text/plain; charset=utf-8',
52 verbose headers 'content-length': '21',
52 verbose headers date: 'Wed, 17 Feb 2016 02:43:01 GMT',
52 verbose headers connection: 'keep-alive' }
53 verbose request invalidating /home/dd/.cnpm/localhost_7001/_40trillers_252ftest2 on PUT
54 error publish Failed PUT 500
55 verbose stack SyntaxError: Unexpected token I
55 verbose stack Internal Server Error
55 verbose stack at Object.parse (native)
55 verbose stack at CachingRegistryClient. (/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/npm-registry-client/lib/request.js:199:23)
55 verbose stack at Request._callback (/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/npm-registry-client/lib/request.js:172:14)
55 verbose stack at Request.self.callback (/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/request/request.js:199:22)
55 verbose stack at emitTwo (events.js:87:13)
55 verbose stack at Request.emit (events.js:172:7)
55 verbose stack at Request. (/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/request/request.js:1036:10)
55 verbose stack at emitOne (events.js:82:20)
55 verbose stack at Request.emit (events.js:169:7)
55 verbose stack at IncomingMessage. (/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/request/request.js:963:12)
56 verbose cwd /home/www/test2
57 error Linux 3.13.0-32-generic
58 error argv "/usr/local/bin/node" "/usr/local/lib/node_modules/cnpm/node_modules/.bin/npm" "--userconfig=/home/dd/.cnpmrc" "--disturl=https://npm.taobao.org/mirrors/node" "--cache=/home/dd/.cnpm" "--registry=http://localhost:7001/" "--node-gyp=/usr/local/lib/node_modules/cnpm/node_modules/node-gyp/bin/node-gyp.js" "publish"
59 error node v4.2.3
60 error npm v2.14.19
61 error Unexpected token I
61 error Internal Server Error
62 error If you need help, you may report this error at:
62 error https://github.com/npm/npm/issues
63 verbose exit [ 1, true ]

config.js

module.exports = {
    debug: false,
    scopes: ['@trillers'],
    enableCluster: true, // enable cluster mode
    mysqlServers: [
      {
        host: 'localhost',
        port: 3306,
        user: 'root',
        password: 'root',
      }
    ],
    mysqlDatabase: 'cnpmjs',
    nfs: null, //use your own CDN here
    enablePrivate: true, 
    admins: {
      admin: '[email protected]',
    },
    syncModel: 'exist'// 'none', 'all', 'exist'
  };

~/.cnpmrc

registry=http://localhost:7001/
[email protected]
//localhost:7001/:always-auth=false
//localhost:7001/:_password="YWRtaW4="
//localhost:7001/:username=admin
//localhost:7001/:[email protected]

package to publish

{
  "name": "@trillers/test2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "co": "^4.6.0"
  }
}
@dead-horse
Copy link
Member

返回500了,看看服务是否记录了错误日志

@leekangtaqi
Copy link
Author

cnpmjs.org下没找到日志文件?

@leekangtaqi
Copy link
Author

帮忙解决下

@dead-horse
Copy link
Member

你怎么启动的服务,日志目录默认是在 $HOME/.cnpmjs.org/log 目录下

@leekangtaqi
Copy link
Author

找到了 config.js里没有设logs选项,添加了logs,看到错误信息
2016-02-17 01:27:20.258 nodejs.TypeErrorException: TypeError: Cannot read property 'uploadBuffer' of null
at Object.save (/home/cnpm/cnpmjs.org/controllers/registry/package/save.js:181:31)
at next (native)
at Object.publishable (/home/cnpm/cnpmjs.org/middleware/publishable.js:45:21)
at next (native)
at Object.login (/home/cnpm/cnpmjs.org/middleware/login.js:41:10)
at next (native)
at Object. (/home/cnpm/cnpmjs.org/node_modules/koa-middlewares/node_modules/koa-router/node_modules/koa-compose/index.js:29:12)
at next (native)
at Object.dispatch (/home/cnpm/cnpmjs.org/node_modules/koa-middlewares/node_modules/koa-router/lib/router.js:97:44)
at next (native)
pid: 10272
Host: ubuntu
URL: /@trillers%2ftest2
Data: ''
2016-02-17 01:27:20.258

@leekangtaqi
Copy link
Author

是cdn的事么?
我nfs设的CDN是null,不用CDN不行吗?

@dead-horse
Copy link
Member

nfs 必须要有,默认是存本地文件的

@kevenfeng
Copy link

存本地不行吗? 我也遇到一样的问题 nfs设置的为null

@dead-horse
Copy link
Member

@kevenfeng 说了默认是存本地的,不要设置成 null,看一下文档 https://github.com/cnpm/cnpmjs.org/wiki/NFS-Guide

@kevenfeng
Copy link

能不能不要在这里面的文档中写null啊!把人带坑里面去了,至少做个详细点的注释把!汗 https://github.com/cnpm/cnpmjs.org/wiki/Deploy

@kevenfeng
Copy link

不过你能回复 还是挺感激 我把那行去掉了就行了!

@fengmk2
Copy link
Member

fengmk2 commented Feb 23, 2016

我将 https://github.com/cnpm/cnpmjs.org/wiki/Deploy 里面的 nfs: null 配置删除了。

@kevenfeng
Copy link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants