Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prerendering makes no name folder on MacOS #3170

Closed
NeeIt opened this issue Jun 11, 2023 · 2 comments
Closed

prerendering makes no name folder on MacOS #3170

NeeIt opened this issue Jun 11, 2023 · 2 comments

Comments

@NeeIt
Copy link

NeeIt commented Jun 11, 2023

When I try to prerender a project on MacOS and ubuntu. Rusult: I have noname folder
macbook pro 14 m1
ubuntu 20

image

Same action with Windows OS does not make this folder

image

I have no idea why this noname folder exists

routes.txt

/
/faq
/blog/news
/blog/news/n/2
/de/blog/news
/de/faq
/de/blog/news/n/2

I use language touting paths for my project like 'de/blog' and '/blog' (english)

app.routing.ts

import { routes as appRoutes } from './app.routes';
...
const MAIN_LANG = 'en';

const notFoundPage = {
  path: '**',
  component: NotFoundPageComponent,
  canActivate: [LanguageGuard],
};
...
export const routes: Routes = [
  {
    path: '',
    component: MainLauoutComponent,
    children: [{
      path: '',
      children: appRoutes,
      canActivate: [LanguageGuard],
      data: {lang: MAIN_LANG},
    },
    ...Object.keys(['es', 'de', 'en']).filter(item => item !== MAIN_LANG).map(lang => ({
      path: lang,
      children: [...appRoutes, notFoundPage],
      canActivate: [LanguageGuard],
      data: {lang}
    })),
    notFoundPage
  ]
  }
];

app.routes.ts

import { Routes } from '@angular/router';

export const routes: Routes = [
  {
    path: '',
    children: [{
        path: 'blog',
        loadChildren: () => import('@project/modules-blog').then((modules) => modules.BlogModule),
      }, {
        path: 'faq',
        loadChildren: () => import('@project/modules-faq').then((modules) => modules.FaqModule),
      }
    ],
  }
];

package.json

{
 ...
  "scripts": {
    "ng": "nx",
    "postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2020 browser module main",
    ...
    "start:dev:ssr": "ng run app:serve-ssr -c=development --port 1617",
    "start:stage:ssr": "ng run app:serve-ssr -c=stage --port 1617",
    "build:ssr": "ng build && ng run app:server ",
    "build:ssr:stage": "ng build --c=stage && ng run app:server --c=stage",
    "serve:ssr": "node dist/app/server/main.js",
    "prerender:project": "ng run app:prerender",
    "prerender:project:stage": "ng run app:prerender --c=stage",
  },
  "private": true,
  "dependencies": {
    "@angular-slider/ngx-slider": "^2.0.4",
    "@angular/animations": "~15.1.0",
    "@angular/cdk": "15.1.1",
    "@angular/common": "~15.1.0",
    "@angular/compiler": "~15.1.0",
    "@angular/core": "~15.1.0",
    "@angular/forms": "~15.1.0",
    "@angular/material": "15.1.1",
    "@angular/platform-browser": "~15.1.0",
    "@angular/platform-browser-dynamic": "~15.1.0",
    "@angular/platform-server": "~15.1.0",
    "@angular/router": "~15.1.0",
    "@nguniversal/express-engine": "^15.2.0",
    "@ngx-translate/core": "^14.0.0",
    "@ngxs-labs/actions-executing": "^0.1.9",
    "@ngxs-labs/dispatch-decorator": "^4.0.2",
    "@ngxs/devtools-plugin": "^3.7.6",
    "@ngxs/form-plugin": "^3.7.6",
    "@ngxs/logger-plugin": "^3.7.6",
    "@ngxs/router-plugin": "^3.7.6",
    "@ngxs/store": "^3.7.6",
    "@nrwl/angular": "15.6.0",
    "@sentry/angular": "^7.32.1",
    "@sentry/integrations": "^7.32.1",
    "@sentry/tracing": "^7.32.1",
    "@types/iframe-resizer": "^3.5.9",
    "@types/moment-timezone": "^0.5.30",
    "animejs": "^3.2.1",
    "axios": "^1.3.6",
    "chart.js": "^4.2.0",
    "chartjs-plugin-datalabels": "^2.2.0",
    "deploy-aws-s3-cloudfront": "^0.2.9",
    "domino": "^2.1.6",
    "express": "^4.15.2",
    "howler": "^2.2.3",
    "iframe-resizer": "^4.3.6",
    "is-ua-webview": "^1.1.2",
    "localstorage-polyfill": "^1.0.1",
    "lru-cache": "^9.1.0",
    "moment": "^2.29.3",
    "moment-timezone": "^0.5.40",
    "ng-in-viewport": "^15.0.0",
    "ng-scrollbar": "^0.0.8",
    "ng2-charts": "^4.1.1",
    "ngx-device-detector": "^5.0.1",
    "ngx-image-cropper": "^6.3.2",
    "ngx-perfect-scrollbar": "^10.1.1",
    "ngx-scrollbar": "^11.0.0",
    "ngx-skeleton-loader": "^6.0.0",
    "ngx-socket-io": "~4.4.0",
    "ngx-webstorage-service": "^5.0.0",
    "ngxs-reset-plugin": "^3.0.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~15.1.0",
    "@angular-eslint/eslint-plugin": "15.0.0",
    "@angular-eslint/eslint-plugin-template": "15.0.0",
    "@angular-eslint/template-parser": "15.0.0",
    "@angular/cli": "~15.1.0",
    "@angular/compiler-cli": "~15.1.0",
    "@angular/language-service": "~15.1.0",
    "@nguniversal/builders": "~15.1.0",
    "@nrwl/cli": "15.6.0",
    "@nrwl/cypress": "15.6.0",
    "@nrwl/eslint-plugin-nx": "15.6.0",
    "@nrwl/jest": "15.6.0",
    "@nrwl/linter": "15.6.0",
    "@nrwl/nx-cloud": "15.0.2",
    "@nrwl/workspace": "15.6.0",
    "@types/animejs": "^3.1.5",
    "@types/express": "^4.17.0",
    "@types/howler": "^2.2.7",
    "@types/jest": "28.1.8",
    "@types/node": "16.11.7",
    "@types/socket.io-client": "^1.4.32",
    "@typescript-eslint/eslint-plugin": "5.36.1",
    "@typescript-eslint/parser": "5.36.1",
    "cypress": "^9.1.0",
    "eslint": "8.15.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-cypress": "^2.10.3",
    "jest": "28.1.3",
    "jest-environment-jsdom": "28.1.1",
    "jest-preset-angular": "12.2.3",
    "ng-packagr": "15.1.1",
    "nx": "15.6.0",
    "postcss": "^8.4.5",
    "postcss-import": "14.1.0",
    "postcss-preset-env": "7.5.0",
    "postcss-url": "10.1.3",
    "prettier": "2.6.2",
    "ts-jest": "28.0.8",
    "ts-node": "10.9.1",
    "typescript": "4.8.4",
    "webpack": "^5.64.0",
    "wrangler": "^2.3.0"
  },
  "engines": {
    "node": ">=16.10.0"
  }
}

server.ts

...

export function app(): express.Express {
  const server = express();
  const distFolder = join(process.cwd(), 'dist/gofast-app/browser');
  const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';

  server.engine('html', ngExpressEngine({
    // NOTE: For SSR application does not run AppModule. Instead of this it runs AppServerModule
    bootstrap: AppServerModule,
  }));

  server.set('view engine', 'html');
  server.set('views', distFolder);

  server.get('*.*', express.static(distFolder, {
    maxAge: '1y'
  }));

  server.get('*', (req: any, res: any) => {
      res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] }, (err: any, render: any) => {
        res.send(render);
      });
  });

  return server;
}

// --------------------------------------

// SSR server start
function run(): void {
  const port = process.env['PORT'] || 4000;

  const server = app();
      server.listen(port, () => {
        console.log(`Node Express server listening on http://localhost:${port}`);
      });
}

// --------------------------------------

declare const __non_webpack_require__: NodeRequire;
const mainModule = __non_webpack_require__.main;
const moduleFilename = mainModule && mainModule.filename || '';
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
  run();
}

export * from './src/app/app.server.module';
@alan-agius4
Copy link
Collaborator

I'm sorry, but we can't reproduce the problem following the instructions you provided.
Remember that we have a large number of issues to resolve, and have only a limited amount of time to reproduce your issue.
Short, explicit instructions make it much more likely we'll be able to reproduce the problem so we can fix it.

If the problem persists, please open a new issue following our submission guidelines.

A good way to make a minimal repro is to create a new app via ng new repro-app and add the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2023
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants