0

I am trying to install and initiate the Typeorm but it gives me an error; I have tried to search about it but nothing seems to work.

First I ran this in the cmd npm i typeorm -g and then typeorm init --name backend-proj-one --database postgres

typeorm : The term 'typeorm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At line:1 char:1
+ typeorm init --name backend-proj-one --database postgres
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (typeorm:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
   

Would you be able to help me?

Ty so much, that would really mean a lot

I was expecting to have the basic files added to my project

Filipa
  • 3
  • 2

2 Answers2

0

It looks like you are trying to run the typeorm command in your terminal, but the terminal is unable to recognize it.

There are a few things you can try to resolve this issue:

Make sure you have installed typeorm correctly by running npm i typeorm in your terminal. This should install typeorm locally in your project.

Make sure you have installed typeorm globally by running npm i -g typeorm. This will allow you to run the typeorm command from any location on your machine.

If you have installed typeorm both locally and globally, try running the command with the npx prefix, like this: npx typeorm init --name backend-proj-one --database postgres. This will use the locally-installed version of typeorm rather than the global version.

If none of the above solutions work, it's possible that there is a problem with your Node.js or npm installation. You can try reinstalling Node.js and npm to see if that resolves the issue.

  • Hello! Thank you, you were a great help, I think I only installed it globally so that was probably one of the issues. Another thing I think made a difference was running the cmd as an Administrator as well. – Filipa Jan 05 '23 at 13:20
0

What's your $PATH and is the global node_modules folder in there? Check out this Link

If Not

Being at the project's root isn't enough. Either the global node_modules folder (not just the one for your project) must be in your $PATH, or you can use npx typeorm if you don't mind doing that instead.

If also this is not working

If you don't care to add the global node_modules folder (not just the project one) to your $PATH, you can use npx {command-name} instead. The global node_modules folder's location depends on your OS.

See Where does npm install package.

One benefit of using npx, however, is that it works with all packages, not just globally installed ones.

Swapnil
  • 94
  • 1
  • 12
  • Thank you for your time and help! changing to "npx" does seem to do the trick as well. I wasnt't aware of the differences between those commands. – Filipa Jan 05 '23 at 13:22