yorkie-team / yorkie-js-sdk

Yorkie JavaScript SDK
https://yorkie.dev/docs/js-sdk
Apache License 2.0
143 stars 95 forks source link

`npm run benchamark` doesn't work in local #313

Closed Eithea closed 2 years ago

Eithea commented 2 years ago

What happened: npm run benchamark doesn't work in local (verified in Windows and Mac)

$ npm run benchmark

> yorkie-js-sdk@0.2.7 benchmark
> ts-node-script ./test/bench/**.ts

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './**.ts'

What you expected to happen:

I expected it works normally like in CI but it returns error.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

The other commands that run ts-node running a single script work normally.

If someone needs to test all bench in local, try ./node_modules/ts-node/dist/bin-script.js ./test/bench/**.ts instead of npm run benchmark.

Environment:

taenykim commented 2 years ago

I found this issue while looking at the GFI 🐤 but it works well for me. It's still not working? If it doesn't work, I would appreciate it if you could share the error reproduction environment in more detail. @Eithea

Eithea commented 2 years ago

@taenykim

both of my laptops use windows10 without WSL and the problem arises.

  1. clone the repository
  2. set all dependancy (npm i, docker ...)
  3. npm run benchmark
$ npm run benchmark

> yorkie-js-sdk@0.2.11 benchmark   
> ts-node-script ./test/bench/**.ts

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './**.ts' 
Require stack:
- ~\yorkie-js-sdk\test\bench\imaginaryUncacheableRequireResolveScript
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at requireResolveNonCached (~\yorkie-js-sdk\node_modules\ts-node\dist\bin.js:257:16)
    at getProjectSearchDir (~\yorkie-js-sdk\node_modules\ts-node\dist\bin.js:227:35)
    at Object.main (~\yorkie-js-sdk\node_modules\ts-node\dist\bin.js:131:27)       
    at Object.<anonymous> (~\yorkie-js-sdk\node_modules\ts-node\dist\bin-script.js:5:7)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '~\\yorkie-js-sdk\\test\\bench\\imaginaryUncacheableRequireResolveScript'  
  ]
}

(~ is installed path)

taenykim commented 2 years ago

This issue seems to be caused by using the glob pattern as argv of ts-node. "ts-node-script test/bench/**.ts"

I think it will be resolved by setting only one path as the entry point without using the glob pattern.

Cause

After testing, some console environments did not support the glob pattern.

case 1 (macOS, zsh) - is working

  1. npm run benchmark
  2. console.log(process.argv)
    [
    '/usr/local/bin/node',
    '/Users/user/Desktop/yorkie-js-sdk/node_modules/.bin/ts-node-script',
    'test/bench/document_test.ts'
    ]

case 2 (Windows, cmd) - is not working

  1. npm run benchmark
  2. console.log(process.argv)
    [
    'C:\\Program Files\\nodejs\\node.exe',
    'C:\\Users\\user\\Desktop\\test\\node_modules\\ts-node\\dist\\bin.js',
    './**.ts' # 🚨 do not support glob
    ]

Reference


Could I try this issue? @mojosoeun @blurfx

blurfx commented 2 years ago

@taenykim Sure :)