NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 195 forks source link

Android run fails #5724

Closed MeroVinggen closed 1 year ago

MeroVinggen commented 1 year ago

Issue Description

When I want to start my app at android platform on Winows 10 it fails on webpack build: "Cannot find module 'jsonfile/utils'".

Full error message:

Searching for devices... Preparing project... Error: Cannot find module 'jsonfile/utils' Require stack:

Reproduction

  1. create app using ns CLI: 'ns create myCoolApp2 --js'
  2. ns platform add android
  3. create & launch virtual device in android studio (api 31/api 26)
  4. ns run android

Relevant log output (if applicable)

Looking for project in 'C:\Users\Admin\Desktop\myCoolApp2'
Project directory is 'C:\Users\Admin\Desktop\myCoolApp2'.
Initializing project identifiers. Config:  {
  id: 'org.nativescript.myCoolApp2',
  appPath: 'app',
  appResourcesPath: 'App_Resources',
  android: { v8Flags: '--expose_gc', markingMode: 'none' }
}
Loading extensions.
Collecting system information...
System information:
{
  "platform": "win32",
  "shell": "C:\\WINDOWS\\system32\\cmd.exe",
  "os": "Windows 10 Home 6.3.19045",
  "procArch": "x64",
  "nodeVer": "16.17.0",
  "npmVer": "9.6.2",
  "nodeGypVer": null,
  "nativeScriptCliVersion": "8.4.0",
  "gitVer": "2.34.1.windows.1",
  "dotNetVer": "4.8.04084",
  "javacVersion": "11.0.13",
  "javaVersion": "11.0.13",
  "javaPath": "C:\\Program Files\\Java\\jdk-11.0.13\\bin\\java.exe",
  "adbVer": "1.0.41",
  "androidInstalled": true,
  "monoVer": null,
  "gradleVer": "7.1.1",
  "isAndroidSdkConfiguredCorrectly": true,
  "xcodeprojLocation": null,
  "itunesInstalled": false,
  "isCocoaPodsWorkingCorrectly": false,
  "isCocoaPodsUpdateRequired": false,
  "pythonInfo": null
}
Current CLI version:  8.4.0
Project dir from hooksArgs is: undefined.
Hooks directories: [ 'C:\\Users\\Admin\\Desktop\\myCoolApp2\\hooks' ]
BeforeHookName for command resolveCommand is before-resolveCommand
Project dir from hooksArgs is: undefined.
Hooks directories: [ 'C:\\Users\\Admin\\Desktop\\myCoolApp2\\hooks' ]
AfterHookName for command resolveCommand is after-resolveCommand
Starting watch on killswitch C:\Users\Admin\AppData\Local\Temp\Mero\KillSwitches\cli
Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.
The stackTrace of the location trying to handle SIGINT is:
    at process.on (C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\nativescript@8.4.0\node_modules\nativescript\lib\nativescript-cli.js:26:28)
    at C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\signal-exit@3.0.7\node_modules\signal-exit\index.js:158:17   
    at Array.filter (<anonymous>)
    at load (C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\signal-exit@3.0.7\node_modules\signal-exit\index.js:156:23)
    at module.exports (C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\signal-exit@3.0.7\node_modules\signal-exit\index.js:62:7)
    at Object.<anonymous> (C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\proper-lockfile@4.1.1\node_modules\proper-lockfile\lib\lockfile.js:331:1)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
spawn: C:\Program Files\nodejs\node.exe "C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\nativescript@8.4.0\node_modules\nativescript\lib\detached-processes\cleanup-process.js" "C:\Users\Admin\AppData\Local\pnpm\global\5\.pnpm\nativescript@8.4.0\node_modules\nativescript\lib\bootstrap.js"
Initializing analytics statuses.
Analytics statuses:  { TrackFeatureUsage: 'disabled', TrackExceptions: 'disabled' }
List of registered commands: /?, apple-login, appstore, appstore|upload, autocomplete, autocomplete|disable, autocomplete|enable, autocomplete|status, build, build|android, build|ios, clean, config, config|get, config|set, create, debug, debug|android, debug|ios, deploy, dev-generate-help, dev-generate-messages, dev-post-install, dev-preuninstall, dev-test, dev-test|android, dev-test|ios, device, devices, devices|android, devices|ios, device|android, device|get-file, device|ios, device|list-applications, device|list-files, device|log, device|put-file, device|run, device|stop, device|uninstall, doctor, doctor|android, doctor|ios, error-reporting, extension, extension|install, extension|uninstall, fonts, generate, help, info, install, migrate, package-manager, package-manager|set, platform, platform|add, platform|clean, platform|remove, platform|update, plugin, plugin|add, plugin|build, plugin|create, plugin|install, plugin|remove, plugin|update, post-install-cli, prepare, preview, proxy, proxy|clear, proxy|set, publish, publish|ios, resources, resources|generate|icons, resources|generate|splashes, resources|update, run, run|android, run|ios, setup, test, test|android, test|init, test|ios, typings, update, usage-reporting
Reading help for command ''. FileName is 'start.md'.

Environment

OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Shell: Not Found
node: 16.17.0
npm: 9.6.2
nativescript: Not Found

# android
java: Not Found
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: Not Found
cocoapods: Not Found
python: Not Found
python3: Not Found
ruby: Not Found
platforms: Not Found

Dependencies

"dependencies": {
  "@nativescript/core": "~8.4.0",
  "@nativescript/theme": "~3.0.2",
  "svelte-native": "~1.0.0"
},
"devDependencies": {
  "@nativescript/android": "8.4.0",
  "@nativescript/types": "~8.4.0",
  "@nativescript/webpack": "~5.0.12",
  "svelte": "~3.44.0",
  "svelte-loader": "^3.1.2",
  "svelte-native-preprocessor": "^1.0.0",
  "svelte-preprocess": "^4.7.0",
  "typescript": "~4.8.4"
}

Please accept these terms

OPADA-Eng commented 1 year ago

I run into the same issue but with a different package. it seems there is an issue with a newer version of the CLI that doesn't install the packages correctly after ns clean command. I used to resolve it by the following:

  1. ns clean
  2. npm i
  3. ns run android

I hope this can be helpful.

MeroVinggen commented 1 year ago

@OPADA-Eng thx for your help, but it didn't solve the problem

rigor789 commented 1 year ago

Looks like you're using pnpm for your global cli install. Try npm or yarn, as pnpm's strict dep layout might be preventing one of our deps from working. There's work going on for updating all of our CLIs dependencies, and that might solve the issue, but I'm not sure.

MeroVinggen commented 1 year ago

I tried with npm all same steps and got new error:

"The webpack configuration file C:\Users\Admin\Desktop\myCoolApp\webpack.config.js does not exist. Ensure the file exists, or update the path in nativescript.config.(js|ts)"

I don't remember if webpack.config was in the previous attempt or not, but unfortunately ns is unusable for now

ghost commented 1 year ago

I second this. Same problem with no resolution in sight.

rigor789 commented 1 year ago

The webpack config missing issue has been fixed today (https://github.com/NativeScript/nativescript-cli/pull/5729), awaiting release in a patch release soon.

Anything else is lacking details, and would be better discussed on Discord: https://nativescript.org/discord

MeroVinggen commented 1 year ago

It works, now we are able to launch common template. Thx for your responding.