I've just started to use Mac iOS and when I started to set up a new backend (TypeScript) project I faced the problem that all the packages in npm scripts do not work.
Cannot find module 'typescript/bin/tsc'
Require stack:
- /Users/valera/Documents/projects/web/bwtc-backend/node_modules/tsc-watch/lib/tsc-watch.js
- /Users/valera/Documents/projects/web/bwtc-backend/node_modules/tsc-watch/index.js
I checked my node_modules folder and even deleted it and npm i
packages again but it did not help. For some reason, it cannot see them or something.
My package.json file:
{
"name": "name",
"main": "server.js",
"private": true,
"scripts": {
"clean": "rm -rf ./dist",
"tsc": "tsc",
"start:build": "npm-run-all clean tsc",
"start:dev": "cross-env NODE_ENV=DEVELOPMENT tsc-watch --onSuccess 'node ./dist/server.js'",
"dev": "npm-run-all clean start:dev",
"prod": "npm-run-all clean start:build"
},
"license": "ISC",
"dependencies": {
"dotenv": "^8.2.0",
"express": "4.17.1",
"telegraf": "^4.0.0"
},
"devDependencies": {
"@types/express": "4.17.11",
"cross-env": "^7.0.3",
"npm-run-all": "^4.1.5",
"tsc-watch": "^4.2.9"
}
}
Nothing special. Everything worked fine on my Windows machine. Maybe there is some special way to use it on Mac, I don't know.
The only workaround I found is to use the packages I need to use in the script npm run dev
for instance, as globally installed and not as a script in the package.json but run the whole script in a terminal (of course with the packages previously installed globally).
I believe it shouldn't be this way.
Can anyone help me out here or has any ideas on the issue?