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

TypeError: Cannot read properties of undefined (reading 'tick') #95

Closed
ghost opened this issue Oct 8, 2022 · 1 comment · Fixed by #96
Closed

TypeError: Cannot read properties of undefined (reading 'tick') #95

ghost opened this issue Oct 8, 2022 · 1 comment · Fixed by #96

Comments

@ghost
Copy link

ghost commented Oct 8, 2022

when I try to run example , it hanppen a bug.

  • only run a fie -- index.js
  • NodeJS version is v16.17.0
  • npm version is 8.18.0

Code

import figures, {replaceSymbols, mainSymbols, fallbackSymbols} from 'figures';

console.log(figures.tick);
// On terminals with Unicode symbols:  ✔︎
// On other terminals:                 √

console.log(figures.mainSymbols.tick);
// On all terminals:  ✔︎

console.log(figures.fallbackSymbols.tick);
// On all terminals:  √

console.log(figures.replaceSymbols('✔︎ check'));
// On terminals with Unicode symbols:  ✔︎ check
// On other terminals:                 √ check`

Report bug

PS C:\Users\shish\code\command-tools> node ./bin/index.js
✔
file:///C:/Users/shish/code/command-tools/bin/index.js:7
console.log(figures.mainSymbols.tick);
                                ^

TypeError: Cannot read properties of undefined (reading 'tick')        
    at file:///C:/Users/shish/code/command-tools/bin/index.js:7:33     
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)     
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)  `
@ehmicky
Copy link
Collaborator

ehmicky commented Oct 8, 2022

Hi @denghauran,

Thanks a lot for pointing this out. Those are typos in the README.md. I have opened #96 to fix them.

replaceSymbols, mainSymbols, fallbackSymbols should use named imports, not the default import. The following should work:

import figures, {replaceSymbols, mainSymbols, fallbackSymbols} from 'figures';

console.log(figures.tick);
// On terminals with Unicode symbols:  ✔︎
// On other terminals:                 √

console.log(mainSymbols.tick);
// On all terminals:  ✔︎

console.log(fallbackSymbols.tick);
// On all terminals:  √

console.log(replaceSymbols('✔︎ check'));
// On terminals with Unicode symbols:  ✔︎ check
// On other terminals:                 √ check`

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

Successfully merging a pull request may close this issue.

1 participant