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

Cannot read property 'search' of null #1402

Open
alessandro-tucci-visiontech opened this issue Jul 12, 2021 · 6 comments
Open

Cannot read property 'search' of null #1402

alessandro-tucci-visiontech opened this issue Jul 12, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@alessandro-tucci-visiontech
Copy link

alessandro-tucci-visiontech commented Jul 12, 2021

🐞 Bug report

ng add @scullyio/init terminates uncorrectly with Cannot read property 'search' of null. I see that another similar issue was opened (#1168) but I'm not seeing any solution. W.r.t. this other issue (#1288), the name of my Angular project is something like xyz-showcase (yes, with the hyphen)

Description

🔬 Minimal Reproduction

Just run ng add @scullyio/init on the already-existing Angular project where I want to integrate scully

💻Your Environment

Angular Version:


Angular CLI: 11.2.14
Node: 15.14.0
OS: win32 x64

Angular: undefined
...
Ivy Workspace: No

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.1102.14
@angular-devkit/build-angular       0.1102.14
@angular-devkit/core                11.2.14
@angular-devkit/schematics          11.2.14
@angular/cli                        11.2.14
@angular/common                     11.2.14
@angular/compiler-cli               11.2.14
@angular/google-maps                12.0.2
@angular/language-service           11.2.14
@angular/platform-browser           11.2.14
@angular/platform-browser-dynamic   11.2.14
@angular/router                     11.2.14
@schematics/angular                 11.2.14
@schematics/update                  0.1102.14
typescript                          4.1.5

Scully Version:

    "@scullyio/init": "~1.1.4",
    "@scullyio/ng-lib": "~1.0.0",
    "@scullyio/scully": "~1.0.0",

🔥 Exception or Error


Skipping installation: Package already installed
Cannot read property 'search' of null
@alessandro-tucci-visiontech alessandro-tucci-visiontech added the bug Something isn't working label Jul 12, 2021
@alessandro-tucci-visiontech
Copy link
Author

alessandro-tucci-visiontech commented Jul 12, 2021

I partly managed to backtrace the problem.
As we can see from here:

const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');

and here:

if (packageJson.dependencies && packageJson.dependencies[name]) {

Scully's schematics are requiring the presence of @angular/core in the dependencies section of the package.json file.
It is a requirement that should be added to the doc, since an explicit @angular/core dependency is not required for a generic Angular project to work.

However, there is still something missing. Now, I'm receiving this error:

  Skipping installation: Package already installed
    ⚠️  Skipping polyfills.ts
    Install ng-lib
    ✅️ Added dependency
UPDATE package.json (1717 bytes)
√ Packages installed successfully.
Cannot set property 'scully' of undefined

@alessandro-tucci-visiontech
Copy link
Author

Another implicit requirement: the package.json file is required to provide a script section, as we can see here:

jsonContent.scripts.scully = 'npx scully --' + params;

Therefore, I was able to add the schematics by adding:

"scripts": {}

to my package.json file

@SanderElias
Copy link
Contributor

@alessandro-tucci-visiontech Thanks for the thorough description. I'll be putting those issues on our to-do

@SanderElias
Copy link
Contributor

@Jefiozie Did we already address this in our schematic updates?

@Jefiozie
Copy link
Collaborator

No I don't think so, assigning it to me for investigation

@SanderElias
Copy link
Contributor

This seems also related to #1520. Not the same issue, but e might be able to solve both with the same solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants