I have the following command:
"scripts": {
"dev": "npx nodemon --watch 'src/**/*.ts' -e ts --exec ts-node --esm src/index.ts"
},
If I run npm run dev
nodemon will start successfully, but If I update any of my .ts files inside the src folder, nodemon won't detect changes in the project and won't re-run the project.
Nevertheless, If I run npx nodemon --watch 'src/**/*.ts' -e ts --exec ts-node --esm src/index.ts
directly in my terminal, it will start successfully too, but this time it will actually detect changes in any of my .ts file in the src folder and re-run the project.
I have the following structure:
āāāāš .vscode/
ā āāāāš types.ts.code-snippets
āāāāš src/
ā āāāāš entities/
ā ā āāāā...
ā āāāāš resolvers/
ā ā āāāā...
ā āāāāš index.ts
āāāāš .gitignore
āāāāš backend-idea.yml
āāāāš package-lock.json
āāāāš package.json
āāāāš tsconfig.json
I tried to change 'src/**/*.ts'
to "./src/**/*.ts"
and it worked exactly like before.
What could be the reason it only works If I execute directly in my terminal and not with npm run dev
? I am in Windows 11, Node v19.9, Powershell 7.3.6. (pwd is in the root directory of the project)
In order to make it work I had to replace the '
to \"
& "\
. So the script looks like that:
"scripts": {
"dev": "npx nodemon --watch \"src/**/*.ts\" -e ts --exec ts-node --esm src/index.ts"
},