Question

App Platform keeps using cached node_modules despite changes

I have been deploying a node.js server application via app platform without issue. In the last push to github, I have introduced typescript which has made significant changes to my package.json and package-lock.json including adding typescript 4.1.3.

my build command is now

"build": "tsc",

But my build is failing because with the following because it can’t find the tsc command. relevant bit of the deployment logs below…

tsystems-server | 16:28:37 Installing node_modules using npm
tsystems-server | 16:28:44 added 119 packages in 5.537s
tsystems-server | 16:28:45 Running custom build command: npm run build
tsystems-server | 16:28:45 
tsystems-server | 16:28:45 > tsystems-server@1.0.0 build /workspace
tsystems-server | 16:28:45 > tsc
tsystems-server | 16:28:45 
tsystems-server | 16:28:45 sh: 1: tsc: not found

Not sure what is going wrong, the npm run build command works locally. I have tried manually referencing “./node_modules/…etc…/tsc” in the build command but that didn’t work. Also tried npx tsc but that just got really wierd.

Any clues?

Michael

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

This is a known issue with App Platform node builds NOT installing dev dependencies (which is really stoopid).

to fix, alter your build command to this.

npm install --only=dev && npm run build && npm prune --production

The issue is discussed here…

https://www.digitalocean.com/community/questions/how-do-you-use-node-js-devdependencies-in-the-app-platform-builds

Hello,

I understand that you are experiencing an issue with compiling TypeScript while building the app. You need to call “tsc” from an npm script by including command such as ( npm install typescript -g ) because I can see the build is failing at below line with “tsc not found” error:

tsc -p ./server/tsconfig.json --outDir ./dist && next build

Can you try this and keep us posted, if this helped!

Cheers, Sri Charan

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.