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

Brand new nx workspace cannot find xplat #73

Closed
brunobertechini opened this issue Jan 21, 2019 · 15 comments
Closed

Brand new nx workspace cannot find xplat #73

brunobertechini opened this issue Jan 21, 2019 · 15 comments
Assignees

Comments

@brunobertechini
Copy link

brunobertechini commented Jan 21, 2019

Just created new nrwl/nx workspace and installed @nstudio/schematics.

ng g xplat --prefix=myprefix --platforms=nativescript

Schematic "xplat" not found in collection "@nrwl/schematics"

Schematic "app.nativescript" not found in collection "@nrwl/schematics".

"@nrwl/nx": "7.4.1",
`ng --version

Package Version

@angular-devkit/architect 0.11.4
@angular-devkit/build-angular 0.11.4
@angular-devkit/build-optimizer 0.11.4
@angular-devkit/build-webpack 0.11.4
@angular-devkit/core 7.1.4
@angular-devkit/schematics 7.1.4
@angular/cli 7.1.4
@ngtools/webpack 7.1.4
@schematics/angular 7.1.4
@schematics/update 0.11.4
rxjs 6.3.3
typescript 3.1.6
webpack 4.23.1
`

@draconis0318
Copy link

Seeing the same with:

@nrwl/schematics:7.5.0
@angular/cli:7.2.2

@NathanWalker
Copy link
Member

@brunobertechini sounds like the postinstall did not run as it should have set the default schematics to @nstudio/schematics. Try running npm i @nstudio/schematics -D with the flag on the end to be sure it installed into devDependencies. Curious if you see it in your package.json devDependencies or not?

@NathanWalker
Copy link
Member

I have been unable to repro this.

In your root package.json ensure you have at least these in there:

"devDependencies": {
    ...
    "@nrwl/schematics": "7.5.0",
    "@nstudio/schematics": "^7.2.3",

Also open angular.json and you can manually adjust to ensure you have this:

"cli": {
    ...
    "defaultCollection": "@nstudio/schematics",
    ...
  },

Alternatively you can also use Angular Console if you have the dependency in your workspace package.json dependencies or devDependencies. You will see @nstudio/schematics and all the options which will use the direct schematic command always (avoiding the need/reliance on a proper default being set in angular.json), ie:

ng generate @nstudio/schematics:app.nativescript myapp

screen shot 2019-01-23 at 7 45 01 pm

screen shot 2019-01-23 at 7 45 21 pm

@NathanWalker
Copy link
Member

@brunobertechini @midsever were you still seeing issue here? Try with 7.2.8 latest of @nstudio/schematics - the issue points to possibility that postinstall did not run to update the default schematics. Not sure what setups would prevent postinstall from running but you might try with latest and if still see issue you can manually update defaults as mentioned above. At anytime you can always use Angular Console to run any schematic in the workspace directly since it doesn't rely on default settings.

@JefferE
Copy link

JefferE commented Feb 2, 2019

This issue has been closed but its still happening. The cause is, in fact, a failure to run the post install as @NathanWalker said. The root cause appears to be a script error. Here's my output when trying to install the schematics:

`PS C:\Users\jleig\Dvlp\nx-on-fire-one> npm install @nstudio/schematics --save-dev

@nstudio/schematics@7.2.8 postinstall C:\Users\jleig\Dvlp\nx-on-fire-one\node_modules@nstudio\schematics
[ ! -f scripts/postinstall.js ] || node scripts/postinstall.js
'[' is not recognized as an internal or external command,
operable program or batch file.`

I just installed all cli's (angular, ionic, nx,...) today and created this workspace so I have the latest of everything. This is what was installed:

"@nrwl/schematics": "7.5.1",
"@nstudio/schematics": "^7.2.8",

Can we get this reopened and the error addressed?

@NathanWalker
Copy link
Member

Thanks for reporting back 👍 - wasn't sure if cleared or not. Definitely so I see you're on Windows and I'm wondering if original reported @brunobertechini is also on Windows? Perhaps could provide a clue.

@NathanWalker NathanWalker reopened this Feb 2, 2019
@NathanWalker
Copy link
Member

/cc @m-abs perhaps the new postinstall syntax is not Windows friendly?

@NathanWalker
Copy link
Member

@JefferE try running it directly with this command:

node node_modules\@nstudio\schematics\scripts\postinstall.js

Lemme know if you get any issue with that.

@JefferE
Copy link

JefferE commented Feb 2, 2019

Hmm, it appears to run (no errors) but it does not update the defaultCollection in Angular.json

It's still set to "defaultCollection": "@nrwl/schematics", after I run it.

@NathanWalker
Copy link
Member

Interesting for sure. This gives us something to go on, thank you.

@m1kl
Copy link

m1kl commented Feb 13, 2019

I also had to set manually the defaultCollection attribute in order to make it work.

@madmath03
Copy link
Contributor

Just encountered the same issue and I'm on Windows 10. Like @NathanWalker said, the new postinstall syntax is not Windows friendly. Is it really necessary to test the existence of the script before running it though ?

I also tried running the postinstall.js script directly and like others it did nothing. After adding some traces, I found out it stops here:

if (cwd.indexOf('node_modules/@nstudio/schematics') === -1) {

This is because on windows the path will contain \ instead of /.

I simply fixed the script by changing the previous line to this:

if (cwd.indexOf('node_modules/@nstudio/schematics') === -1 && cwd.indexOf('node_modules\\@nstudio\\schematics') === -1) {

Post install works fine with this.

@NathanWalker I can create a PR for the latest if you want.

@NathanWalker
Copy link
Member

This is fantastic @madmath03 thank you! Yes a PR would be much appreciated. And we can probably remove that syntax on postinstall.

A couple months back I setup a new workstation and don’t have a windows environment setup yet so been hard to clear the windows related issues.

madmath03 added a commit to Monogramm/xplat that referenced this issue Feb 14, 2019
@draconis0318
Copy link

I apologize for not responding earlier but I wanted to confirm as well that I'm on a Windows 10 environment and I did basically the same thing as madmath03 and that seemed to work. If I manually changed the defaultCollection as suggested I wasn't able to create an app. I don't receive any errors and no files are produced.

@NathanWalker
Copy link
Member

No worries @midsever - this fix is now available in 7.2.9 now thanks to @madmath03 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants