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

Cannot find package 'typescript' imported #142

Closed
multipliedtwice opened this issue Dec 15, 2021 · 10 comments
Closed

Cannot find package 'typescript' imported #142

multipliedtwice opened this issue Dec 15, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@multipliedtwice
Copy link

multipliedtwice commented Dec 15, 2021

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

@multipliedtwice multipliedtwice added the bug Something isn't working label Dec 15, 2021
@ivanhofer
Copy link
Owner

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

@multipliedtwice
Copy link
Author

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

@ivanhofer
Copy link
Owner

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

@multipliedtwice
Copy link
Author

@ivanhofer
image

@ivanhofer
Copy link
Owner

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

@jeromecc
Copy link

jeromecc commented Jan 5, 2022

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

@ivanhofer
Copy link
Owner

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

@jeromecc
Copy link

jeromecc commented Jan 5, 2022

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

@ivanhofer
Copy link
Owner

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

@ivanhofer
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants