typescript runs strange on heroku - node.js

I have a typescript project and want my running code to get generated by heroku when I deploy. I therefore added "postinstall": "tsc" to package.json so that tsc would be run on heroku after npm install is complete (I do have typescript in my dependencies).
It does run, but for some reason, tsc crashes with RangeError: Maximum call stack size exceeded on an obscure file .heroku/node/lib/node_modules/npm/node_modules/slide/lib/async-map-ordered.js which it shouldn't be running on at all. This setup works perfectly on my machine, on Circle.ci, and on a freshly cloned repo.
I had a theory that maybe tsc was being run in the wrong directory, but when I used pwd && ls && tsc It printed the correct directory (/tmp/build_5292b1b9c3c13c35489f46510acb565e) and the files that are in my directory.
My question is: Why is tsc running in this strange way on heroku, and what do I have to do to make typescript work on a heroku deployment?

Related

How can I deploy a Vite Node.js app on Heroku? Everything I do seems to build but fails to run

I am deploying using Github (automatic fetching and building from the repository). The project version there is the dev version, but since Heroku builds it first, it shouldnt be a problem.
First Heroku fetches and builds the project, which always succeeds:
See here
But, right after that, when Heroku tries to run and deploy the build, it says "vite" is not found:
See here
If i run it locally it works. If i build and preview it locally it also works.
Does anyone know what I should do to make this work?
I tried checking my package.json for "dependencies" vs "devDependencies" differences and added "vite" to the "dependencies" section:
See here
The Procfile they advise to use I've tried running "npm run start", "npm start", "npm i && npm start" and "npm i && npm run start", but all of them give the same exact error. Also tried it with "npx" but it fails to install vite.
After i contacted their support, they just said it falls outside of their "support policy".
I just want this to be able to run, since it works when i run it locally and when i build and preview it.
EDIT: After moving both vite and vite plugins to the dependencies instead of the devDependencies, i got this message See here

Node.js is causing error: Missing script: "start"?

I just started studying front-end development and I'm struggling with a node.js error.
Typing 'npm start' in my VSCode terminal used to work fine for simple tutorial projects with just an index.html, script.js, and style.css file. (without a package.json file)
However after trying out React for the first time, 'npm start' now doesn't work anymore in my other non-React projects. At first it was giving me an error that it was missing the package.json (which it didn't need before?) but after trying to fix it with help of googling I now got to a point where it's giving me the error: Missing script: "start".
How can I run node without creating package.json files for every small tutorial project I've made previously, or without turning them into React apps? Also why is this happening? Did installing React-native create dependencies of some sort?
Thanks in advance!
I already tried reinstalling node.js and tried different versions. Also tried deleting package-lock.json. It still works for React apps, just not with simpler native javascript apps.
A package.json file is required if you want to install any packages or run scripts in your terminal. In your package.json file, make sure you have added scripts property. This is an example of how you can use it:
{
...
"scripts": {
"start": "react-scripts start"
}
}
Remove ... from the snippet if you're copying, this has been added to indicate that there are one or more fields in this JSON file.
After you have added this to your package file, you will be able to run the start script by typing npm run start in the terminal or if you use Yarn: yarn start.
Edit:
You said that running npm start in your React project is running fine, but on your simpler projects with only a simple HTML, CSS and JS file is not working when using the script.
You are probably confusing npm start with node file.js. Where node file.js doesn't require a package to be in your project to run a JavaScript file, using npm start requires you to have a JSON file present in your project folder with the JSON code as in my answer.
So long story short: Using npm start requires package.json with the script property available. While node file.js doesn't require you to have this file in your project.
if you are using react-native you can do the following
First you have to build your project with the command
npx react-native run-android , npx react-native run-ios
Once your project has build successfully and app is installed on your device then you your development server is started already. for some reason if your server is closed then you can run it with the command given below.
adb reverse tcp:8081 tcp:8081 this will send a signal to your device and after this run npx react-native start

Jest not recognizing Yarn workspace module in CircleCI

My tests run fine locally, but in CircleCI I get this error “Cannot find module ‘shared-data-model’” which is one of my Yarn workspaces.
The stack trace of the error points to Resolver.resolveModule (../node_modules/#jest/core/node_modules/jest-resolve/build/index.js:276:11)
I am running
Jest 25.1.0,
Yarn 1.22,
Node.js 12.16
Any ideas what could be causing this? Thank you
I figured out the problem. I am using typescript CLI tsc to transpile my module from /src to /dist, and I wasn't running the transpile step on CI to generate the /dist folder, so when it tried to find the entrypoint of the module dist/index.js there was nothing there. Once I ran the build tsc step in CI it worked as expected.

Can't find the dist file

This is a noob question but when I run npm run build on a vue app I am working on, I get the following message:
rimraf dist; node build/build.js
I don't understand what that means, but worse I don't see a dist file created anywhere (which I need to run locally).
Where is it?
What does the output mean?
turns out a ";" won't work on windows, I needed to build directly through node not using a preset npm command.

execute ng serve pointing to the angular directory from current directory

working with angular2 App, and i am writing .bat scripts to automate the angular build and serving the application, as part of the ng serve. I have to do like
c:\abc\edf>ng serve --server=d:\angualr2\demoApp
Here demoApp is angular2 and node_modules already installed i need to up the angulap app by my batch script.
Where as everyone knows it works and working for me too.
d:\angualr2\demoApp>ng serve
if you build the application, then you don't serve it with ng serve
the flag --server is unknown to me, and to the CLI documentation (--help)
If you have a path issue, start by goign into the right folder of your file explorer with cd D:\angular2\demoApp (not sure about it, I'm more of a Linux man)
ng works because NPM added it to your PATH. If you work on another computer, it won't work. Consider running with the local package with a npm command such as npm run build, where build: "ng build --prod"

Resources