Nativescript: tns preview ERROR in nativescript.config.ts:1:10 - error TS2305: Module '"HelloWorld/node_modules/@nativescript/core"' has no exported member 'NativeScriptConfig'.

Created on 2 Sep 2020  Β·  23Comments  Β·  Source: NativeScript/NativeScript

Environment
Windows 10
Node v12.18.3
√ Component nativescript has 7.0.3 version and is up to date.
√ Component tns-core-modules has 6.5.16 version and is up to date.
Γ— Component @nativescript/ios is not installed.
√ Component @nativescript/android has 7.0.0 version and is up to date.

Describe the bug
tns preview produces this error:

ERROR in nativescript.config.ts:1:10 - error TS2305: Module '"HelloWorld/node_modules/@nativescript/core"' has no exported member 'NativeScriptConfig'.

To Reproduce
tns create HelloWorld --template tns-template-blank-ng
cd HelloWorld
tns preview
(scan code from phone)

Most helpful comment

tns-template-blank-ng is outdated, the right template for ns7 is @nativescript/template-blank-ng - the docs need to be updated.

All 23 comments

Hi @Rafael-Anier ,
Thank you for reporting this issue.
You could try to follow the below-attached steps and to verify, whether the problem will exist after the changes.

1) delete node_modules, platforms, hooks folders from the project.
2) clean npm cache with npm cache clean
3) delete the project from the simulator (if checking on simulator)
4) build it again with tns run android/ios
5) tns preview

If the problem persists please send us the whole project, which will allow us to debug it locally.
Let me know, how it goes.

Hello I have the same problem as Rafael-Anier :(

If you can't upgrade your tns-core-modules or @nativescript/core remove the import from the config and remove the as NativeScriptConfig part - that should still work fine, but you will lose autocompletion for the configuration properties.

Hi.
I Tried the Ross-Olivares method and the problem still remains.
I uploaded the code to:
https://github.com/Rafael-Anier/HellloWorld

Thanks a lot and kind regards.
Rafa

@Rafael-Anier have you tried my suggestions?

Hi @rigor789
I don`t know how to do any of your suggestions. ΒΏcan you guide me to do it?

Thanks a lot and kind regards.
Rafa

@Rafael-Anier nothing more than removing the lines I mentioned:

-import { NativeScriptConfig } from '@nativescript/core'

export default {
  id: 'org.nativescript.app',
  appPath: 'app',
  appResourcesPath: 'app_resources',
  android: {
    v8Flags: '--expose_gc',
    markingMode: 'none',
  },
-} as NativeScriptConfig
+}

Hi Rigor, i tried and raise another error, thanks for your assistance, but i think that by the moment this platform is too avanced for my skills, i'm going to return to my old Android Platform and maybe try it in another moment.

Thanks a lot and kind regards.
Rafael Reina

@Rafael-Anier no worries!

I'm also seeing this issue.
@rigor789 is there a commit to make those commented changes from the tns-template-blank-ng template?

There seems to be a dependency issue with the template.

npx tns create HelloWorld --template tns-template-blank-ng
cd HelloWorld
npm install --save-dev nativescript
npm install
npx tns run android --device Pixel_3_XL_API_30



Using tns-android v6.5.0 which requires nsconfig.json to be present.
Writing nsconfig.json based on the values set in nativescript.config.(js|ts).
You may add nsconfig.json to .gitignore as the CLI will regenerate it as necessary.

File change detected. Starting incremental webpack compilation...

webpack is watching the files…

Hash: f03c085e787ac44c3d02
Version: webpack 4.27.1
Time: 8586ms
Built at: 09/14/2020 11:50:48 AM
 3 assets
Entrypoint bundle = runtime.js vendor.js bundle.js
[./app.css] 1.18 KiB {bundle} [built]
[./main.ts] 1.16 KiB {bundle} [built]
[~/package.json] external "~/package.json" 42 bytes {bundle} [optional] [built]
    + 373 hidden modules

ERROR in nativescript.config.ts:1:10 - error TS2305: Module '"./node_modules/@nativescript/core"' has no exported member 'NativeScriptConfig'.

1 import { NativeScriptConfig } from '@nativescript/core';

I modified as mentioned in comment https://github.com/NativeScript/NativeScript/issues/8807#issuecomment-689050881

Results in

The current application is not compatible with NativeScript CLI 7.0.

Run 'ns migrate' to migrate your project to NativeScript 7.

Alternatively you may try running it with '--force' to skip this check.

after running

:~/repos/bitbucket/trash-nativescript/HelloWorld$ npx ns migrate --force
⚠ Not in Git repo, but using --force
βœ” Pre-Migration verification complete
βœ” Project files have been backed up
βœ” Cleaned directory hooks
β„Ή Skipping platforms because it doesn't exist.
βœ” Cleaned directory node_modules
βœ” Cleaned file webpack.config.js
βœ” Cleaned file package-lock.json
βœ” Cleaned file tsconfig.tns.json
βœ” Project files have been cleaned up
βœ” Cleaned old artifacts
β ™ Migrating project to use nativescript.config.tsFailed to update config.Error: Cannot find module './parser-typescript'
β Ή Migrating project to use nativescript.config.tsFailed to update config.Error: Cannot find module './parser-typescript'
Failed to update config.Error: Cannot find module './parser-typescript'
β Έ Migrating project to use nativescript.config.tsFailed to update config.Error: Cannot find module './parser-typescript'

Failed to update nativescript.config.ts.

Please manually update nativescript.config.ts and set appPath to src.

Failed to update config.Error: Cannot find module './parser-typescript'
Failed to migrate project to use nativescript.config.ts. One or more values could not be updated.

Seems the dependencies on the template or migration util is not working as expected. I recommend this be opened again as it is blocking new users from following https://docs.nativescript.org/start/cli-basics

Thanks,

tns-template-blank-ng is outdated, the right template for ns7 is @nativescript/template-blank-ng - the docs need to be updated.

Deleted folder and tried again. Now I see nativescript launch script followed with an exception.

npx tns create HelloWorld --template @nativescript/template-blank-ng
cd HelloWorld/
npm install --save-dev nativescript
npx tns run android --device Pixel_3_XL_API_30
WARNING in /home/leblanc/repos/bitbucket/trash-nativescript/HelloWorld/nativescript.config.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

......


Restarting application on device emulator-5554...
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)

emulator shows the following stacktrace

An uncaught Exception occurred on "main" thread.
Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.

StackTrace:
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)
    at android.app.ActivityThread.access$1300(ActivityThread.java:237)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
    at com.tns.Module.bootstrapApp(Module.java:316)
    at com.tns.Runtime.run(Runtime.java:680)
    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
    ... 8 more
Caused by: com.tns.NativeScriptException: Failed to find module: "./", relative to: app//
    at com.tns.Module.resolvePathHelper(Module.java:151)
    at com.tns.Module.bootstrapApp(Module.java:314)
    ... 12 more

Running

npx tns preview --bundle
before
npx tns run android --device Pixel_3_XL_API_30

runs the app but without hot reloading (making a change causes white blank page)

trying to use preview app instead of emulator npx tns preview --bundle results in this:
https://github.com/NativeScript/nativescript-schematics/issues/290

If you are in angular this template works completely with hot module reloading inside an android emulator:
git clone --depth 1 https://github.com/NativeScript/nativescript-sdk-examples-ng.git

uses angular 9.1.0

You are using npx tns run - what version of the CLI does it resolve to? The --bundle is not needed, all apps are bundled with webpack since 6.x I believe.

I can see the

WARNING in .../nativescript.config.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

This shouldn't affect anything - but will need to be updated in the template (the tsconfig file).

I don't know the status of HMR in angular, but you can use --no-hmr if that solves the white screen issue.

what version of the CLI does it resolve to?

the version i installed with npm install --save-dev nativescript currently that is [email protected]. The template needs to be fixed and angular 10 seems to be causing issues https://github.com/NativeScript/nativescript-schematics/issues/290.

@leblancmeneses some updates were just pushed to the templates. You may need to set appPath: 'src' in the config (will also be addressed in a cli update soon).

-import { NativeScriptConfig } from '@nativescript/core'

export default {
  id: 'org.nativescript.app',
  appPath: 'app',
  appResourcesPath: 'app_resources',
  android: {
    v8Flags: '--expose_gc',
    markingMode: 'none',
  },
-} as NativeScriptConfig
+}

Same issue trying with --template tns-template-drawer-navigation-ng. As @rigor789 said: removing lines from /nativescript.config.ts file will work.

I created template from this :

tns create my-blank-ng --template tns-template-blank-ng
removed the lines from nativescript.config.ts

tns run android gives me the following error :

Project successfully built.
The build result is located at: /Users/johnwesley/AndroidStudioProjects/github/template/my-blank-ng/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Installing on device emulator-5554...
Successfully installed on device with identifier 'emulator-5554'.
Application org.nativescript.myblankng is not running on device emulator-5554.
This issue may be caused by:
    * crash at startup (try `tns debug android --debug-brk` to check why it crashes)
    * different application identifier in your package.json and in your gradle files (check your identifier in `package.json` and in all *.gradle files in your App_Resources directory)
    * device is locked
    * manual closing of the application
Unable to apply changes on device: emulator-5554. Error is: Application org.nativescript.myblankng is not running.



tns-template-blank-ng is outdated, the right template for ns7 is @nativescript/template-blank-ng - the docs need to be updated.

I think this is confusing a lot of people, i got stuck on this error until i see your comment.

Hey guys I'm also having issues migrating:

karl@karl-Dell-Precision-M3800:~/dev/basickarl/passer-mobile$ npx ns migrate
βœ” Pre-Migration verification complete
βœ” Project files have been backed up
βœ” Cleaned directory hooks
βœ” Cleaned directory platforms
βœ” Cleaned directory node_modules
βœ” Cleaned file webpack.config.js
βœ” Cleaned file package-lock.json
β„Ή Skipping tsconfig.tns.json because it doesn't exist.
βœ” Project files have been cleaned up
βœ” Cleaned old artifacts
β ‹ Migrating project to use nativescript.config.tsFailed to update config.Error: Cannot find module 'fs-extra'
Require stack:
- /home/karl/dev/basickarl/passer-mobile/node_modules/@ts-morph/common/dist/ts-morph-common.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/ts-morph/dist/ts-morph.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/tools/config-manipulation/config-transformer.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/services/project-config-service.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/common/yok.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/bootstrap.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/nativescript-cli.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/bin/tns
Failed to update config.Error: Cannot find module 'fs-extra'
Require stack:
- /home/karl/dev/basickarl/passer-mobile/node_modules/@ts-morph/common/dist/ts-morph-common.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/ts-morph/dist/ts-morph.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/tools/config-manipulation/config-transformer.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/services/project-config-service.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/common/yok.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/bootstrap.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/nativescript-cli.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/bin/tns
Failed to update config.Error: Cannot find module 'fs-extra'
Require stack:
- /home/karl/dev/basickarl/passer-mobile/node_modules/@ts-morph/common/dist/ts-morph-common.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/ts-morph/dist/ts-morph.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/tools/config-manipulation/config-transformer.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/services/project-config-service.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/common/yok.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/bootstrap.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/nativescript-cli.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/bin/tns

Failed to update nativescript.config.ts.

Please manually update nativescript.config.ts and set android.maxLogcatObjectSize to 5000.

Failed to update config.Error: Cannot find module 'fs-extra'
Require stack:
- /home/karl/dev/basickarl/passer-mobile/node_modules/@ts-morph/common/dist/ts-morph-common.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/ts-morph/dist/ts-morph.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/tools/config-manipulation/config-transformer.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/services/project-config-service.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/common/yok.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/bootstrap.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/nativescript-cli.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/bin/tns

Failed to update nativescript.config.ts.

Please manually update nativescript.config.ts and set id to io.basickarl.passer.

Failed to update config.Error: Cannot find module 'fs-extra'
Require stack:
- /home/karl/dev/basickarl/passer-mobile/node_modules/@ts-morph/common/dist/ts-morph-common.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/ts-morph/dist/ts-morph.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/tools/config-manipulation/config-transformer.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/services/project-config-service.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/common/yok.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/bootstrap.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/nativescript-cli.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/bin/tns

Failed to update nativescript.config.ts.

Please manually update nativescript.config.ts and set appPath to app.

Failed to update config.Error: Cannot find module 'fs-extra'
Require stack:
- /home/karl/dev/basickarl/passer-mobile/node_modules/@ts-morph/common/dist/ts-morph-common.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/ts-morph/dist/ts-morph.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/tools/config-manipulation/config-transformer.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/services/project-config-service.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/common/yok.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/bootstrap.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/lib/nativescript-cli.js
- /home/karl/dev/basickarl/passer-mobile/node_modules/nativescript/bin/tns

Failed to update nativescript.config.ts.

Please manually update nativescript.config.ts and set appResourcesPath to app/App_Resources.

βœ” Cleaned file nativescript.config.ts
Failed to migrate project to use nativescript.config.ts. One or more values could not be updated.

Part of my package.json:

    "nativescript": {
        "id": "io.basickarl.passer",
        "templateVersion": "v2",
        "tns-android": {
            "version": "6.5.1"
        },
        "tns-ios": {
            "version": "6.5.1"
        }
    },
    "dependencies": {
        "@vue/devtools": "5.3.3",
        "email-validator": "2.0.4",
        "nativescript-permissions": "1.3.9",
        "nativescript-platform-css": "1.6.10",
        "nativescript-socketio": "3.3.1",
        "nativescript-sqlite": "2.6.3",
        "nativescript-toasty": "3.0.0-alpha.2",
        "nativescript-vue": "2.6.1",
        "nativescript-vue-devtools": "1.4.0",
        "tns-core-modules": "6.5.4",
        "vuex": "3.3.0"
    },
    "devDependencies": {
        "@babel/core": "7.0.0",
        "@babel/preset-env": "7.0.0",
        "babel-loader": "8.1.0",
        "eslint": "7.1.0",
        "nativescript": "6.7.4",
        "nativescript-dev-webpack": "1.5.1",
        "nativescript-vue-template-compiler": "2.6.0",
        "nativescript-worker-loader": "0.11.0",
        "node-sass": "4.13.1",
        "sass-loader": "8.0.2",
        "tns-platform-declarations": "6.5.5",
        "vue-loader": "15.9.1"
    }

I've done the following:
delete node_modules, platforms, hooks folders from the project.
clean npm cache with npm cache clean
delete the project from the simulator (if checking on simulator)
build it again with tns run android/ios
tns preview

Was this page helpful?
0 / 5 - 0 ratings