Open
Description
Issue Description
Create an a new TyepScript
app and initialize it for testing with mocha
. When running the tests there is an error that the karma.conf.js
is missing.
Reproduction
ns create MyApp --ts
cd MyApp
npm install --legacy-peer-deps
ns platform add android
ns test init --framework=mocha
ns test android --emulator --justlaunch
OR for iOS (same result):
ns create MyApp --ts
cd MyApp
npm install --legacy-peer-deps
ns platform add ios
ns test init --framework=mocha
ns test ios --emulator --justlaunch
Relevant log output (if applicable)
Searching for devices...
22 02 2022 15:48:25.625:WARN [karma-server]: Passing raw CLI options to `new Server(config, done)` is deprecated. Use `parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` to prepare a processed `Config` instance and pass that as the `config` argument instead.
22 02 2022 15:48:25.630:ERROR [config]: Error in config file!
Error: Cannot find module '/Users/adriann/Developer/MyApp/karma.conf.js'
Require stack:
- /Users/adriann/Developer/MyApp/node_modules/karma/lib/config.js
- /Users/adriann/Developer/MyApp/node_modules/karma/lib/server.js
- /Users/adriann/.nvm/versions/node/v16.14.0/lib/node_modules/nativescript/lib/services/karma-execution.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.parseConfig (/Users/adriann/Developer/MyApp/node_modules/karma/lib/config.js:433:22)
at new Server (/Users/adriann/Developer/MyApp/node_modules/karma/lib/server.js:81:22)
at process.<anonymous> (/Users/adriann/.nvm/versions/node/v16.14.0/lib/node_modules/nativescript/lib/services/karma-execution.js:11:23)
at process.emit (node:events:520:28)
at emit (node:internal/child_process:938:14)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
Test run failed.
Environment
Environment
Result of echo 'y' | npx nativescript-envinfo
OS: macOS 11.5.2
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Shell: /bin/bash
node: 16.14.0
npm: 8.5.1
nativescript: 8.1.5
# android
java: 11.0.11
ndk: Not Found
apis: 29, 30, 31, 32
build_tools: 29.0.2, 29.0.3, 30.0.1, 30.0.2, 30.0.3, 31.0.0
system_images:
- android-23 | Google APIs Intel x86 Atom_64
- android-24 | Google APIs Intel x86 Atom_64
- android-24 | Google Play Intel x86 Atom
- android-25 | Google APIs Intel x86 Atom_64
- android-26 | Google APIs Intel x86 Atom_64
- android-27 | Google APIs Intel x86 Atom
- android-28 | Google Play Intel x86 Atom_64
- android-29 | Google Play Intel x86 Atom_64
- android-30 | Google Play Intel x86 Atom_64
- android-31 | Google Play Intel x86 Atom_64
- android-32 | Google Play Intel x86 Atom_64
# ios
xcode: 12.5.1/12E507
cocoapods: 1.11.2
python: 2.7.16
python3: 3.9.10
ruby: 2.7.5
platforms:
- iOS 14.5
- DriverKit 20.4
- macOS 11.3
- tvOS 14.5
- watchOS 7.4
Dependencies
"dependencies": {
"@nativescript/core": "~8.1.1",
"@nativescript/theme": "~3.0.1",
"@nativescript/unit-test-runner": "^3.0.2"
},
"devDependencies": {
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@nativescript/types": "~8.1.1",
"@nativescript/webpack": "~5.0.0",
"@types/karma-chai": "0.1.2",
"@types/mocha": "9.0.0",
"chai": "4.3.6",
"karma": "6.3.16",
"karma-chai": "0.1.0",
"karma-coverage": "2.0.3",
"karma-mocha": "2.0.1",
"karma-nativescript-launcher": "0.4.0",
"mocha": "9.1.3",
"nyc": "15.1.0",
"typescript": "~4.3.5"
}
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted beforeThis is a bug reportI agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
adrian-niculescu commentedon Mar 10, 2022
Retested this after NativeScript CLI 8.2.2 was released
still does not work out-of-the-box, but after adding
"@nativescript/android": "^8.2.2",
todevDependencies
inpackage.json
it workedCurrent working environment (after manual adjustments):
Dependencies
rigor789 commentedon Mar 10, 2022
These work for me - the only change I had to make (which I'm fixing in the default karma config) was to add
hostname: '127.0.0.1'
because in node17localhost
get's resolved to the ipv6 address by default, and causes the following error:Using
127.0.0.1
forces it to use ipv4...Committed the fix here - will publish along with other fixes later... 81cb9c3
adrian-niculescu commentedon Mar 14, 2022
Ran:
with the following error:
Full logs
Environment
Dependencies
adrian-niculescu commentedon Mar 14, 2022
Using
Dependencies
then
ns test android --emulator --justlaunch
works as expected.
Observed discrepancies:
@nativescript/android
version 7.0.1@nativescript/android
is not added by the NativeScript CLI topackage.json
ns platform update android
does upgrade the project to use@nativescript/android@8.2.2
but I have the same error with this version.@nativescript/android@8.1.1
-> works as expected.rigor789 commentedon Mar 14, 2022
That's strange - seems like an npm cache issue locally? It uses latest 8.2.2 for me as expected.
Not after
ns create
but after running the app first - it should be added automatically ("@nativescript/android": "8.2.2"
)Check
package.json
-~8.2.2
should work, but try with just8.2.2
without the tilde and see if that makes a difference? TheInvalid Version: null.
usually meant an unparsable version number somewhere, though I fixed many cases like that in the CLI, and I haven't seen that pop up for a while now. You can run with--log trace
to get a stack-trace of where that's coming from, might help me fix it in the cli.Does that mean no
~
(tilde) in the version? Might be related to above?Running the same exact commands:
Yields this on both my mac and windows machines:
adrian-niculescu commentedon Mar 14, 2022
I cleared the npm cache via
(I have npm installed via nvm
then:
It says it adds the **7.**0.1 version not 8.2.2.⚠️
also tried:
I checked to see if
@nativescript/android
is installed:So that's the real problem⚠️
after
I still don't see⚠️
@nativescript/android
inpackage.json
or innode_modules
(seems like a CLI issue)works 👍
I think I just needed a
ns clean; npm install
there. So this can be considered ok.TL;DR
The remaining issues are:
@nativescript/android
is not added automatically topackage.json
and not installed innode_modules
atns test android --emulator --justlaunch
orns run android
, leading to errors such asInvalid Version: null.
. -> workaround:npm install @nativescript/android --save-dev; ns clean; npm install
@nativescript/android
v 7.0.1 by default (but actually no version is installed).rigor789 commentedon Mar 14, 2022
Unable to reproduce unfortunately - can you run with
--log trace
and share the logs? Have no idea why it would pull in 7.0.1 either, unless you are on a 7.x CLIns -v
?adrian-niculescu commentedon Mar 14, 2022
ns -v 8.2.2 - Checking for updates... ✔ Up to date.
Logs for
ns test android --emulator --justlaunch --log trace
logs1.log
Reading the logs I've noticed errors that reference this directory
which I did not know existed and which was not affected by
npm uninstall -g nativescript
. Do you think it's related?Should I manually delete these files?
rigor789 commentedon Mar 14, 2022
Delete
/Users/adriann/.local/share/.nativescript-cli/user-settings.json
- that seems to be invalid too (likely unrelated, but good to clean stuff up to make sure)adrian-niculescu commentedon Mar 15, 2022
I don't have the
user-settings.json
file actually.ls -alh ~/.local/share/.nativescript-cli/user-settings.json ls: /Users/adriann/.local/share/.nativescript-cli/user-settings.json: No such file or directory
As indicated in my reply above:
adrian-niculescu commentedon Mar 15, 2022
and repeated the scenario; same error.
Andreea1998 commentedon Mar 15, 2022
I could also replicate the "Invalid Version:null" problem.
ns create myTestApp --ts; cd myTestApp; ns test init --framework=mocha; ns test android --emulator --justlaunch
leads to
And I have:
`echo 'y' | npx nativescript-envinfo
Dependencies
rigor789 commentedon Mar 15, 2022
Can someone with an M1 run this command (@triniwiz @NathanWalker):
This is what I get
Running
echo 'y' | npx nativescript-envinfo
afterwards, shows the runtime indevDependencies
and everything works (tested on a windows10 and a macos 12.2.1 machine, same outcome)`echo 'y' | npx nativescript-envinfo` output
Dependencies
adrian-niculescu commentedon Mar 15, 2022
I also tried with your version of the CLI
with the same error as before.
rigor789 commentedon Mar 15, 2022
I'm using
@next
only to use the127.0.0.1
ip in the karma config since I'm on node 17 - otherwise it should be identical. Let see if anyone else with an M1 can run the above and report their results - I'm frankly out of ideas what could possibly be causing it to install old runtime, and not add it to package.json for you...adrian-niculescu commentedon Mar 15, 2022
Thank you!
Note that I am on using an Intel mac (Mac Mini 2018);
@Andreea1998 is using M1 according to the env info.
I also tried to replicate your env more exactly
with the same error as before.