Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不兼容cnpm 4.2.0 #5

Open
wssgcg1213 opened this issue May 3, 2016 · 3 comments
Open

不兼容cnpm 4.2.0 #5

wssgcg1213 opened this issue May 3, 2016 · 3 comments

Comments

@wssgcg1213
Copy link
Member

LOG:

 ~  Sites  15:06:12  git clone https://github.com/17koa/koa2-demo.git             [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
Cloning into 'koa2-demo'...
remote: Counting objects: 91, done.
remote: Total 91 (delta 0), reused 0 (delta 0), pack-reused 91
Unpacking objects: 100% (91/91), done.
Checking connectivity... done.
 ~  Sites  15:06:21  cd koa2-demo                                                 [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
 ~  Sites  koa2-demo  master  15:06:25  cnpm i                                  [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]
[co@^4.6.0] installed at node_modules/.npminstall/co/4.6.0/co (0 packages, use 675ms, speed 67.66kB/s, json 46.28kB, tarball 0B)
[[email protected]] deprecate: Jade has been renamed to pug, please install the latest version of pug instead of jade
[debug@^2.2.0] installed at node_modules/.npminstall/debug/2.2.0/debug (0 packages, use 1s, speed 132.65kB/s, json 136.36kB, tarball 0B)
[koa-convert@^1.2.0] installed at node_modules/.npminstall/koa-convert/1.2.0/koa-convert (0 packages, use 1s, speed 137.38kB/s, json 150.7kB, tarball 0B)
[koa-router@^7.0.0] installed at node_modules/.npminstall/koa-router/7.0.1/koa-router (0 packages, use 2s, speed 217.25kB/s, json 351.29kB, tarball 0B)
[koa-json@^1.1.1] installed at node_modules/.npminstall/koa-json/1.1.3/koa-json (0 packages, use 2s, speed 213.94kB/s, json 351.29kB, tarball 0B)
[koa-static@^1.5.2] installed at node_modules/.npminstall/koa-static/1.5.2/koa-static (0 packages, use 2s, speed 291.01kB/s, json 851.21kB, tarball 0B)
[koa-logger@^1.3.0] installed at node_modules/.npminstall/koa-logger/1.3.0/koa-logger (0 packages, use 3s, speed 289.02kB/s, json 976.29kB, tarball 0B)
[koa-views@^5.0.1] installed at node_modules/.npminstall/koa-views/5.0.1/koa-views (0 packages, use 2s, speed 287.23kB/s, json 979.17kB, tarball 0B)
[koa-bodyparser@^2.0.1] installed at node_modules/.npminstall/koa-bodyparser/2.0.1/koa-bodyparser (0 packages, use 4s, speed 284.07kB/s, json 1.12MB, tarball 0B)
[[email protected]] deprecate: Jade has been renamed to pug, please install the latest version of pug instead of jade
[[email protected]] deprecate: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
[should@^8.3.0] installed at node_modules/.npminstall/should/8.3.1/should (0 packages, use 3s, speed 312.93kB/s, json 1.72MB, tarball 0B)
[koa-onerror@^1.2.1] installed at node_modules/.npminstall/koa-onerror/1.3.1/koa-onerror (0 packages, use 6s, speed 311.54kB/s, json 1.83MB, tarball 0B)
[mocha@^2.4.5] installed at node_modules/.npminstall/mocha/2.4.5/mocha (0 packages, use 5s, speed 315.93kB/s, json 2.02MB, tarball 0B)
[jade@~1.11.0] installed at node_modules/.npminstall/jade/1.11.0/jade (0 packages, use 7s, speed 316.51kB/s, json 2.11MB, tarball 0B)
[supertest@^1.2.0] installed at node_modules/.npminstall/supertest/1.2.0/supertest (0 packages, use 5s, speed 289.24kB/s, json 2.28MB, tarball 0B)
[runkoa@^1.5.1] installed at node_modules/.npminstall/runkoa/1.5.2/runkoa (0 packages, use 8s, speed 260.07kB/s, json 2.28MB, tarball 0B)
[[email protected]] download from binary mirror: {"module_name":"fse","module_path":"./lib/binding/{configuration}/{node_abi}-{platform}-{arch}/","remote_path":"./v{version}/","package_name":"{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz","host":"https://npm.taobao.org/mirrors/fsevents"}
[nodemon@^1.9.1] installed at node_modules/.npminstall/nodemon/1.9.2/nodemon (0 packages, use 8s, speed 248.39kB/s, json 2.32MB, tarball 0B)
[koa@^2.0.0] installed at node_modules/.npminstall/koa/2.0.0/koa (0 packages, use 11s, speed 227.8kB/s, json 2.42MB, tarball 11.45kB)
excute post install scripts...
[[email protected]] scripts.install: "node-pre-gyp install --fallback-to-build" at /Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/fsevents/1.0.12/fsevents
node-pre-gyp http GET https://npm.taobao.org/mirrors/fsevents/v1.0.12/fse-v1.0.12-node-v46-darwin-x64.tar.gz
node-pre-gyp http 200 https://npm.taobao.org/mirrors/fsevents/v1.0.12/fse-v1.0.12-node-v46-darwin-x64.tar.gz
[fsevents] Success: "/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/fsevents/1.0.12/fsevents/lib/binding/Release/node-v46-darwin-x64/fse.node" is installed via remote
[[email protected]] scripts.install success, use 2s
All packages installed (353 packages installed from npm registry, use 13s, speed 194.54kB/s, json 442(2.42MB), tarball 11.45kB)
 ~  Sites  koa2-demo  master  15:06:45  npm start                               [Node:v4.4.2 npm:3.8.5 cnpm:4.2.0]

> [email protected] start /Users/Liuchenling/Sites/koa2-demo
> nodemon bin/run

[nodemon] 1.9.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node bin/run`
2babel presets path = /Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall//1.5.2/runkoa
/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:220
          throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
          ^

ReferenceError: Unknown plugin "/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall//1.5.2/runkoababel-plugin-add-module-exports" specified in "base" at 0, attempted to resolve relative to "/Users/Liuchenling/Sites/koa2-demo/bin"
    at /Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:220:17
    at Array.map (native)
    at Function.normalisePlugins (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:196:20)
    at OptionManager.mergeOptions (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:317:36)
    at OptionManager.init (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-core/6.8.0/babel-core/lib/transformation/file/options/option-manager.js:506:10)
    at compile (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-register/6.8.0/babel-register/lib/node.js:112:69)
    at loader (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-register/6.8.0/babel-register/lib/node.js:158:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Liuchenling/Sites/koa2-demo/node_modules/.npminstall/babel-register/6.8.0/babel-register/lib/node.js:168:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
[nodemon] app crashed - waiting for file changes before starting...

我修改 node_modules/runkoa/index.js 里这部分成这样就可以了

require('babel-core/register')({
    plugins: [require('babel-plugin-add-module-exports'), require('babel-plugin-transform-es2015-modules-commonjs')],
    presets: [require('babel-preset-es2015-node5'), require('babel-preset-stage-3')],
    babelrc: false
  })  

cnpm 用的 npminstall 的目录结构是软链的, 所以直接用__dirname 来拼接dir路径是会报错的, 我觉得可以直接用require('xxx')这种写法是babel 文档中支持的, 另一种是利用path.join(), 后者我没试过 可以试试

@wssgcg1213
Copy link
Member Author

wssgcg1213 commented May 3, 2016

https://github.com/cnpm/cnpm

cnpm最新的就是4.2.0

这个镜像国内还是很多人用的吧

@knight42
Copy link

knight42 commented Jun 15, 2016

@wssgcg1213 感谢~ 👍 . 建议给 https://github.com/17koa/runkoa 提 PR

  var dir =  __dirname + '/node_modules/'
  var plugin_dir = dir + 'babel-plugin-'
  console.log('3babel presets path = ' + dir)
  // npm 3.x set babel in entry file
  require('babel-core/register')({
    plugins: [plugin_dir + 'add-module-exports', plugin_dir + 'transform-es2015-modules-commonjs'],
    presets: [dir + 'babel-preset-es2015-node5', dir + 'babel-preset-stage-3'],
    babelrc: false
  })  

话说这么拼接路径真是不知道说什么好...

@i5ting
Copy link
Contributor

i5ting commented Jun 15, 2016

@knight42 runkoa本身就是个hack方案,哈哈

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

No branches or pull requests

3 participants