Environment
Provide version numbers for the following components (information can be retrieved by running tns info
in your project folder or by inspecting the package.json
of the project):
Describe the bug
When following the development workflow step for testing tns-core-modules inside your own app, the app will stop with the following runtime error:
Error: com.tns.NativeScriptException: Failed to find module: "tslib", relative to: app/tns_modules/
com.tns.Module.resolvePathHelper(Module.java:146)
com.tns.Module.resolvePath(Module.java:55)
com.tns.Runtime.runModule(Native Method)
com.tns.Runtime.runModule(Runtime.java:553)
com.tns.Runtime.run(Runtime.java:545)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
android.app.ActivityThread.-wrap1(Unknown Source:0)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loop(Looper.java:164)
android.app.ActivityThread.main(ActivityThread.java:6494)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
File: "<unknown>, line: 1, column: 265
StackTrace:
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'file:///data/data/org.nativescript.hacktober/files/app/tns_modules/tns-core-modules/globals/ts-helpers.js', line: 13, column: 13
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'file:///data/data/org.nativescript.hacktober/files/app/tns_modules/tns-core-modules/globals/globals.js', line: 2, column: 1
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'file:///data/data/org.nativescript.hacktober/files/app/tns_modules/tns-core-modules/application/application-common.js', line: 2, column: 1
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'file:///data/data/org.nativescript.hacktober/files/app/tns_modules/tns-core-modules/application/application.js', line: 5, column: 28
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'file:///data/data/org.nativescript.hacktober/files/app/app.js', line: 7, column: 19
Frame: function:'require', file:'', line: 1, column: 266
To Reproduce
tns create Demo; cd Demo
npm link tns-core-modules
tns run ios/android
Expected behavior
The app should start with no error.
Hey @surdu than you for reporting this one - I can confirm that indeed there is an issue that can be reproduced when using npm link
with the latest modules. We will investigate further - meanwhile instead of using npm link
for your development, you could directly create a file reference to the modified modules.
For examples
npm install ../../NativeScript/tns-core-modules --save
where the path depends on your local repository location
@NickIliev - To my knowledge (NPM as of v4) when doing a npm install ../anypath/
will automatically convert it to a npm link ../anypath
Anything that is a local directory is linked
The only way to work around this it to pack it into a module first:
cd ../../NativeScript/tns-core-modules
{{ Update package.json so that it is a version that does NOT exist, i.e. 4.2.10 }}
npm pack
npm i ../../NativeScript/tns-core-modules-4.2.10.tgz --save
@NathanaelA I've just cammed to the same conclusion (the local path being linked and not working) - thanks for the additional info!
Hi @surdu,
Adding tslib
as a dependency in your project should resolve the issue with tns-core-modules
linking. Run the npm install tslib --save
command and check if you still facing an issue with project build.
@tsonevn yap! that solves it!
Thank you everybody for the help!
Hi @surdu,
Can you test if you will be able to recreate the issue with the latest NativeScript version 5.0? You can check our upgrade instruction here.
@tsonevn Unfortunately, I'm still on MacOS Sierra 馃槥 I have plans to upgrade soon though. I'll test it ASAP.
Hi @surdu,
I have tested this case on my side, and I am no longer able to recreate the problem. I think that we can close the issue for now. If it persists on your side, I will reopen the issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @surdu,
Adding
tslib
as a dependency in your project should resolve the issue withtns-core-modules
linking. Run thenpm install tslib --save
command and check if you still facing an issue with project build.