scullyio / scully

The Static Site Generator for Angular apps
https://scully.io/
MIT License
2.56k stars 257 forks source link

Nx workspace: Could not find project "undefined" in 'angular.json' #1491

Open d-koppenhagen opened 2 years ago

d-koppenhagen commented 2 years ago

🐞 Bug report

Description

When creating a NX workspace and adding scully, starting it initially won't work and leads to the error message Could not find project "undefined" in 'angular.json' (see full error message below).

🔬 Minimal Reproduction

1.) create a nx workspace with an angular app

npx create-nx-workspace scully-plugins
npx: installed 48 in 4.391s
✔ What to create in the new workspace · angular
✔ Application name                    · scully-plugin-demo
✔ Default stylesheet format           · css
✔ Use Nx Cloud? (It's free and doesn't require registration.) · No

2.) add a node library (this is maybe not necessary)

chore: add @nrwl/node
npx nx g @nrwl/node:lib scully-plugin-foo

3.) add scully as described in the scully docs

npm install @scullyio/init
nx g @scullyio/init:install -- --project=scully-plugin-demo

The file scully.scully-plugin-demo.config.ts has been created correctly

💻Your Environment

Angular Version:

nx version:


Angular CLI: 13.0.4
Node: 16.13.1
Package Manager: npm 8.1.2
OS: darwin x64

Angular: 13.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.4
@angular-devkit/build-angular   13.0.4
@angular-devkit/core            13.0.4
@angular-devkit/schematics      13.0.4
@angular/cli                    13.0.4
@schematics/angular             13.0.4
rxjs                            7.4.0
typescript                      4.4.4

Scully Version:


"@scullyio/init": "^2.0.5",
"@scullyio/ng-lib": "^2.0.0",
"@scullyio/scully": "^2.0.0",
"@scullyio/scully-plugin-puppeteer": "^2.0.0",

🔥 Exception or Error


npm run scully      

> scully-plugins@0.0.0 scully
> npx scully --

  ⚠ 
      =====================================================================================================
      Config file "./scully.undefined.config.ts" not found, only rendering routes without parameters
      The config file should have a name that is formated as:
          scully..config.ts
      where  is the name of the project as defined in the 'angular.json' file
      If you meant to build a different project as undefined you can use:
          --project differentProjectName as a cmd line option

      When you are in a mixed mono-repo you might need to use the --pjFirst flag.
       which will look for package.json instead of angular.json to find the 'root' of the project.
    =====================================================================================================

  x Could not find project "undefined" in 'angular.json'.

Running npx scully --pjFirst will lead to the same result.

Handing over the config file explicitely will work:

npx scully --cf scully.scully-plugin-demo.config.ts
brendanalexdr commented 2 years ago

Am running into this too. However, npx scully --cf scully.myapp.config.ts does not solve anything.

dimakuba commented 2 years ago

the same issue here

paulorgl commented 2 years ago

i tried to run npx scully --project other using flag target: 'targets' in my config file. But does not solve.

TetianaNazarova commented 2 years ago

https://stackoverflow.com/questions/73442069/no-scully-configuration-file-found-scully-undefined-config-ts-path-scully-unde/73442528#73442528

TetianaNazarova commented 2 years ago

Could not find project "undefined" in 'angular.json'.

The right solutions is here!!!

in angular.json add in the root of the object: "defaultProject": "my-blog",

{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "defaultProject": "my-blog", "projects": { "my-blog": { "projectType": "application", "schematics": { "@schematics/angular:component": { "style": "scss" } },

And name the scully file as scully.my-blog.config.ts

Sergiobop commented 2 years ago

Yeah, defaultProject is deprecated in Angular 14 and removed when you do ng update commands I had to add it again to make scully work as @TatyanaMolchanova said.

morenoisidro commented 2 years ago

Same here. Thanks @TatyanaMolchanova .

FanYeeChok commented 1 year ago

Currently im using NX v14.1.9 with Angular v13.3.12. Here my config file

scully.web-showroom.config.ts


import {ScullyConfig, setPluginConfig} from '@scullyio/scully';
import '@scullyio/scully-plugin-puppeteer';
/** this loads the default render plugin, remove when switching to something else. */
import { baseHrefRewrite } from '@scullyio/scully-plugin-base-href-rewrite';
import { getHttp404Plugin } from '@gammastream/scully-plugin-http404';

const Http404Plugin = getHttp404Plugin();
setPluginConfig(baseHrefRewrite, { href: '/abc' });

export const config: ScullyConfig = {
  projectRoot: "./apps/web-showroom/src",
  projectName: "web-showroom",
  distFolder: './dist/apps/web-showroom',
  spsModulePath: 'YOUR OWN MODULE PATH HERE',
  outDir: './dist/static',
  defaultPostRenderers: [Http404Plugin,'seoHrefOptimise', baseHrefRewrite],
  target: 'targets',
  handle404: 'index',
  routes: {
  }
};

npx scully --scanRoutes --cf=scully.web-showroom.config.ts

its able to generate the static file. Hope can help