NativeScript / nx

NativeScript for Nx.
Other
61 stars 15 forks source link

🚨 Having trouble with 'nx build nativescript-{yourapp}'? See... #51

Open NathanWalker opened 2 years ago

NathanWalker commented 2 years ago

A new requirement is that every flag with a value must be separated with an = to ensure any flags which should never be duplicated are properly deduped (in event it was accidentally added twice):

Case 1

Notice the usage of = between key/values.

Case 2

If you notice your build command turning into nx run or ns debug in a CI Pipeline you may need to use an alternate format, for example:

nx build nativescript-app:ios:prod

――――――――――――――――――――――――
Running NativeScript CLI within apps/nativescript-app/
ns debug ios --no-hmr --env.uglify --env.production --for-device --release

Wait what?! Notice the nx build turned into ns debug - that's not what we want.

nx run nativescript-app:build:prod --platform=ios

――――――――――――――――――――――――
Running NativeScript CLI within apps/nativescript-app/
ns build ios --no-hmr --env.uglify --env.production --for-device --release

There we go, it properly builds now.

JakeAi commented 2 years ago

@NathanWalker Whatever was updated since 3.0.14 kind of makes this unusable, especially without an example project.json. No matter what I do it runs a debug command, or I get an error for isUnitTesting or

The arguments 'C:\Program Files\nodejs\node.exe C:\Development\repo\node_modules\nx\bin\run-executor.js' are not valid for the current command.
NathanWalker commented 2 years ago

@NathanWalker Whatever was updated since 3.0.14 kind of makes this unusable, especially without an example project.json. No matter what I do it runs a debug command, or I get an error for isUnitTesting or

The arguments 'C:\Program Files\nodejs\node.exe C:\Development\repo\node_modules\nx\bin\run-executor.js' are not valid for the current command.

@JakeAi I believe you got past that but ping back here if not.

JakeAi commented 2 years ago

@NathanWalker Whatever was updated since 3.0.14 kind of makes this unusable, especially without an example project.json. No matter what I do it runs a debug command, or I get an error for isUnitTesting or

The arguments 'C:\Program Files\nodejs\node.exe C:\Development\repo\node_modules\nx\bin\run-executor.js' are not valid for the current command.

@JakeAi I believe you got past that but ping back here if not.

nx run nativescript-monitor:build:prod --platform=android

―――――――――――――――――――――――― πŸ€–
Running NativeScript CLI within apps/nativescript-monitor

ns build android --no-hmr --env.uglify --env.production --for-device --release --key-store-path=E:\Development\Android\android.keystore --key-store-password=notforyou --key-store-alias=monitor --key-store-alias-
password=notforyou --env.replace="../../libs/data/default-env/src/lib/data-default-env.ts:../../libs/data/default-env/src/lib/data-default-env.prod.ts,./src/environments/environment.ts:./src/environments/environment.prod.ts" --force C:\Program Files\nodejs\node.exe C:\Development\minnich\node_modules\nx\bin\run-executor.js

Note: When using extra cli flags, ensure all key/value pairs are separated with =, for example: --provision="Name"

---
Error while loading nativescript-cloud is: Default commands should be required before child commands
The arguments 'C:\Program Files\nodejs\node.exe C:\Development\minnich\node_modules\nx\bin\run-executor.js' are not valid for the current command.
Run ns build android --help for more information.
NathanWalker commented 2 years ago

@JakeAi can you run the following:

node -v
npm -v
ns -v

and paste the output here?

Then also can run:

npm install -g nativescript

And confirm version once more:

ns -v
JakeAi commented 2 years ago

@JakeAi can you run the following:

node -v
npm -v
ns -v

and paste the output here?

Then also can run:

npm install -g nativescript

And confirm version once more:

ns -v

v14.18.2 6.14.15 Error while loading nativescript-cloud is: Default commands should be required before child commands 8.2.3 √ Up to date.

Error while loading nativescript-cloud is: Default commands should be required before child commands 8.2.3 √ Up to date.

NathanWalker commented 2 years ago

@JakeAi you will want at least node 15 or higher (we recommend 17 or 18). Additionally you can run this command:

ns extension uninstall nativescript-cloud

That is an old and no longer used extension.

JakeAi commented 2 years ago

@JakeAi you will want at least node 15 or higher (we recommend 17 or 18). Additionally you can run this command:

ns extension uninstall nativescript-cloud

That is an old and no longer used extension.

I now get this


Note: When using extra cli flags, ensure all key/value pairs are separated with =, for example: --provision="Name"

---
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn ns.cmd ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn ns.cmd',
  path: 'ns.cmd',
  spawnargs: [
    'build',
    'android',
    '--no-hmr',
    '--env.uglify',
    '--env.production',
    '--for-device',
    '--release',
    '--key-store-path=E:\\Development\\Android\\android.keystore',
    '--key-store-password=',
    '--key-store-alias=monitor',
    '--key-store-alias-password=',
    '--env.replace="../../libs/data/default-env/src/lib/data-default-env.ts:../../libs/data/default-env/src/lib/data-default-env.prod.ts,./src/environments/environment.ts:./src/environments/environment.prod.ts"',
    '--force',
    'C:\\Program Files\\nodejs\\node.exe',
    'C:\\Development\\repo\\node_modules\\nx\\bin\\run-executor.js'
  ]
}
NathanWalker commented 2 years ago

If you now run the following what versions do you have:

node -v
npm -v
ns -v
JakeAi commented 2 years ago

If you now run the following what versions do you have:

node -v
npm -v
ns -v

I'm currently dealing with https://github.com/npm/cli/issues/4234 Ill let you know when I figure out how to fix it

JakeAi commented 2 years ago

node -v npm -v ns -v

This is the error. The previous error was related to that issue i linked.

The arguments 'C:\Program Files\nodejs\node.exe C:\Development\minnich\node_modules\nx\bin\run-executor.js' are not valid for the current command.
Run ns build android --help for more information.

v18.4.0 8.12.1 8.2.3 √ Up to date.

NathanWalker commented 2 years ago

@JakeAi how about nx version as well? npx nx --version or yarn nx --version from root of your workspace. Now that you have node updated you would likely benefit from doing a npx nx migrate latest and run through the steps to get on latest across the board.

JakeAi commented 2 years ago

@NathanWalker as of right now, 14.1.0.

Edit: now I can't build lol.

Edit 2: Updating ngtools webpack fixed the issue below. I still have The arguments C:\Program Files\nodejs\node.exe C:\Development\repo\node_modules\nx\bin\run-executor.js' are not valid for the current command.


C:\Development\repo\node_modules\typescript\lib\typescript.js:42537
        ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
                 ^

Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
    at Object.resolveTypeReferenceDirective (C:\Development\repo\node_modules\typescript\lib\typescript.js:42537:18)
    at C:\Development\repo\node_modules\@ngtools\webpack\src\ivy\host.js:169:35
    at Array.map (<anonymous>)
    at host.resolveTypeReferenceDirectives (C:\Development\repo\node_modules\@ngtools\webpack\src\ivy\host.js:168:32)    at actualResolveTypeReferenceDirectiveNamesWorker (C:\Development\repo\node_modules\typescript\lib\typescript.js:116674:163)
    at resolveTypeReferenceDirectiveNamesWorker (C:\Development\repo\node_modules\typescript\lib\typescript.js:116974:26)
    at processTypeReferenceDirectives (C:\Development\repo\node_modules\typescript\lib\typescript.js:118456:31)
    at findSourceFileWorker (C:\Development\repo\node_modules\typescript\lib\typescript.js:118341:21)
    at findSourceFile (C:\Development\repo\node_modules\typescript\lib\typescript.js:118196:26)
    at processImportedModules (C:\Development\repo\node_modules\typescript\lib\typescript.js:118602:25)
    at findSourceFileWorker (C:\Development\repo\node_modules\typescript\lib\typescript.js:118347:17)
    at findSourceFile (C:\Development\repo\node_modules\typescript\lib\typescript.js:118196:26)
    at processImportedModules (C:\Development\repo\node_modules\typescript\lib\typescript.js:118602:25)
    at findSourceFileWorker (C:\Development\repo\node_modules\typescript\lib\typescript.js:118347:17)
    at findSourceFile (C:\Development\repo\node_modules\typescript\lib\typescript.js:118196:26)
    at processImportedModules (C:\Development\repo\node_modules\typescript\lib\typescript.js:118602:25)

Node.js v18.4.0
NathanWalker commented 2 years ago

We sorted the above for @JakeAi it was related to some project.json setups and placement of options however also related to fact that keyStorePath flags should be passed in with the build command, for example:

nx run nativescript-app:build:prod --platform=android --keyStorePath="./my.keystore" --keyStoreAlias="alias" --keyStorePassword="pw" --keyStoreAliasPassword="aliasPw" --copyTo="./dist/build.apk"
wearetelescopic commented 2 years ago

Having the same issue - no matter what I run, nx build or nx run always results in a ns debug

and then just opens the app on the phone again. How can one get to a production build??

JakeAi commented 2 years ago

Having the same issue - no matter what I run, nx build or nx run always results in a ns debug

and then just opens the app on the phone again. How can one get to a production build??

Use the 5.0 beta. It's much better.

wearetelescopic commented 2 years ago

Well I upgraded and yes, its not nicely building it. BUT, now its not running on the phone any more...any hints on how to get this going again?