I’m trying to deploy a typescript node.js/express server. I can’t npm install -g typescript - looks like I don’t have the right permissions. For now, I can just include my entire build in my repository, but is there a better way to run typescript projects?
Hey @adrian, I noticed this issue again today when I tried to deploy. Haven’t had any issues running the tsc command for the past 2 months, but today I get command not found. tsc is available from shell, but not working on the deploy. Any ideas?
If you have typescript in your package.json as a dependency or dev dependency, you should be able to run tsc as npx tsc. And, if you add it to your package.json under scripts, then you should be able to run it via npm run ...
update: I got the build working by changing the build command in my package .json to npm install && tsc - prepending npm install to that command fixed the issue, though I’m not sure why
Ah yes, you’ll have to run npm or yarn beforehand to get the dependencies. If you’re using tsc (or any other npm/yarn-installed command) outside of the context of npm/yarn, you’ll need to npm install beforehand as well.
If you have typescript as a dev dependency, make sure you don’t have your node env set to production or else npm i won’t install typescript and tsc will fail.