ivanhofer / typesafe-i18n

A fully type-safe and lightweight internationalization library for all your TypeScript and JavaScript projects.

Home Page:https://github.com/ivanhofer/typesafe-i18n

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find package 'typescript' imported

multipliedtwice opened this issue · comments

Describe the bug

npx: installed 1 in 1.144s
internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'typescript' imported from /Users/danil.t/.npm/_npx/91854/lib/node_modules/typesafe-i18n/cli/typesafe-i18n.mjs
    at new NodeError (internal/errors.js:322:7)
    at packageResolve (internal/modules/esm/resolve.js:687:9)
    at moduleResolve (internal/modules/esm/resolve.js:728:18)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
    at link (internal/modules/esm/module_job.js:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Reproduction

create new nextjs app with ts, try to add typesafe-i18n

Logs

No response

Config

No response

Additional information

No response

Hi @thousandsofraccoons,
have you installed typescript as a devDependency in your project?

yes, nextjs adds it by default if --typescript flag is specified

can you try to install typescript as a global dependency?
npm install - g typescript

Strange.
@thousandsofraccoons can you please try to install typesafe-i18n via

npm install typesafe-i18n

and then run it from within the node_modules folder:

./node_modules/typesafe-i18n/cli/typesafe-i18n.mjs

Hi!
Had the same problem.
I ran:
npm install typesafe-i18n
./node_modules/typesafe-i18n/cli/typesafe-i18n.mjs
the last command hangs so in 'control+C'ed it
then:
npx typesafe-i18n --setup-auto
and it seems to solve the problem

What operating system are you using?
Which version of node?
Which version of npm?

  • Debian 11
  • Node.js v14.18.2.
  • npm 6.14.15

I'm not sure but I think the problem is that npm version < 7.x.x does not install peerDependencies. This was added in version 7.

I can't add typescript as a devDependency because I need the generator to create the types for the TypeScript version you are using in your project. If I would include typescript, then types could be generated, you project does't support yet.

I'll update the Documentation and mention an alternative way to install typesafe-i18n

I have added a troubleshoot section to the docs: https://github.com/ivanhofer/typesafe-i18n#installing-typesafe-i18n-fails

Feel free to reopen this issue if you still encounter some probplems when installing typesafe-i18n.