I have 2 NestJs projects on Vagrant created VMs. One on a ubuntu/jammy box and a new project in a ubuntu noble VM I created by myself using this procedure.
The project in jammy, watches files correctly. So I copied the exact configuration to the new noble machine. But the project in noble’s VM is not watching files.
I just created a new nestjs project and copied the files from the jammy’s VM to noble’s VM. It has no code in it besides the initial default project.
What am I doing wrong ? does noble has some different configuration than jammy in this aspect ?
Here are the relevant files:
Vagrantfile (commented lines removed):
Vagrant.configure("2") do |config|
config.vm.box = "nelson777/ubuntu64-noble"
config.vm.network "public_network", ip: "192.168.0.77", bridge: "enp2s0"
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
end
if Vagrant.has_plugin?("vagrant-timezone")
config.timezone.value = :host
else
puts "ATTENTION: vagrant-timezone plugin not available"
end
config.trigger.after :up do |trigger|
trigger.run = {inline: "bash -c 'vagrant fsnotify > output.log 2>&1 &'"}
end
config.vm.provision "shell", inline: <<-SHELL
<not relevant configuration specific to my project>
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
<not relevant configuration specific to my project>
SHELL
package.json start:dev line:
"start:dev": "nest start --watch --tsc --preserveWatchOutput --host 0.0.0.0",
tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": false,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"esModuleInterop": true,
"resolveJsonModule": true,
"watchOptions": {
"watchFile": "usePolling",
"watchDirectory": "usePolling",
"fallbackPolling": "dynamicPriority",
"synchronousWatchDirectory": true,
"excludeDirectories": [
"**/node_modules",
"**/.git",
"dist"
]
},
"include": [
"./src/**/*",
]
}
}
nest-cli.json:
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
main.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
app.enableCors({
origin: '*'
});
await app.listen(configService.get<string>('SERVER_PORT'));
}
bootstrap();
app.module.ts:
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
cache: true
})],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
You need to sign in to view this answers