In Nativescript after-prepare hook, I want to find out the current platform that the nativescript is preparing for so that I can do different things. So I added
require("platform");
But when I do tns prepare android, I always get the following error:
Error: Cannot find module 'platform'
When I tried adding require("http"); above the require("platform");, require("http");does not give me error. What is the difference between these two cases? Why require("platform"); fails but require("http"); succeed?
Both http module and platform module are in tns-core-modules folder.
You cannot use the TNS core modules inside the hooks. Depending on what your trying to do maybe it would be better to use gulp or something like it. Then create scripts in your package.json to do the processes you need for either platform and then run the nativescript process.
for example.
package.json
scripts": {
"android-stuff": "gulp yourTask && tns run android",
Related
I'm getting this error when trying to build iOS app with flutter module injected in it. I added the FLUTTER_ROOT and flutter dependencies in pod are successfully installed but the build fails getting this error:
ERROR: Unknown FLUTTER_BUILD_MODE: vedur_dev.
Valid values are 'Debug', 'Profile', or 'Release' (case insensitive).
This is controlled by the FLUTTER_BUILD_MODE environment variable.
If that is not set, the CONFIGURATION environment variable is used.
You can fix this by either adding an appropriately named build
configuration, or adding an appropriate value for FLUTTER_BUILD_MODE to the
.xcconfig file for the current build configuration (Vedur_Dev).
I added FLUTTER_BUILD_MODE in User-Defined Settings in TARGETS App like this:
And assigned the values iOS understands. I clean the project, but getting exactly the same error.
I'm not sure where am I making a mistake.
Edit: App builds just fine without the module.
We have seen this on our build system as well. The problem seems to be that the flutter scripts can't figure out what kind of build you are running. So to set the FLUTTER_BUILD_MODE environment variable to Release fixed it.
Valid values are Debug, Profile, or Release
Guide for setting enviroment variables for Xcode. (Or via scripts.)
I have an Angular flavoured Nativescript project.
After follwoing the steps from https://docs.nativescript.org/tooling/testing/testing I encountered the following error:
ERROR in ./src/tests/example.ts Module build failed (from
../node_modules/#ngtools/webpack/src/index.js): Error:
/home/..../src/tests/example.ts is missing from the TypeScript
compilation. Please make sure it is in your tsconfig via the 'files'
or 'include' property.
The steps I did:
tns test init - enter on jasmine
npm i #types/jasmine --save-dev
started my android emulator
tns run android
You can see that the generated example test file does not work, but I did not read anything on the site about modifying the tsconfig.json.
One possible solution is to ... do exactly as the error message says.
after inserting this:
"include": ["src/tests/**/*.ts"]
to the tsconfig.json (or tsconfig.tns.json), the tests run without a problem.
Although I think this means, this file gets included in every build (not just test runs) so not the best solution yet. Including this line only in the tsconfig.spec.json did not help either, it seems I have to prepare a different build for production which will not include this.
I have created Xamarin.UITest that can run locally on my desktop. My goal is to execute these test as a part of a post-build script to run UITest after the app has built as mentioned in this article below:
https://tomsoderling.github.io/AppCenter-Automated-UI-tests-on-build/
Below is my script
appcenter test run uitest --app "MY-APP" --devices 168683d9 --app-path $APPCENTER_OUTPUT_DIRECTORY/MyApp.Mobile.Droid.apk --test-series "myapp-mobile-test" --locale "en_US" --build-dir $APPCENTER_SOURCE_DIRECTORY/MyApp.Mobile.UITests/bin/Release --token MY-TOKEN --uitest-tools-dir $APPCENTER_SOURCE_DIRECTORY/packages/Xamarin.UITest.*/tools
When the script above is apart of my appcenter post build script, I get the following error:
Error: Cannot find test-cloud.exe, the path specified by "--uitest-tools-dir" was not found.
Please check that "/Users/vsts/agent/2.141.1/work/1/s/packages/Xamarin.UITest.2.2.6/tools" is a valid directory and contains test-cloud.exe.
Minimum required version is "2.2.0".
I think a lot of people are having trouble dealing with this actually and I know it has something to do with --uitest-tools-dir OR --build-dir variables.
Keep in mind this I am first trying to do this with Xamarin.Android, if successful I will try the Xamarin.iOS
One clue i do see is when Tom says "I had to chose to build the app solution file in my App Center CI build - not simply the iOS project like I normally would" in the noted article, but I am not quite sure how to do that or if is connected to why AppCenter cannot locate my test-cloud.exe I will also say that test-cloud.exe somehow comes from the Xamarin.UITest nuget, but I do not see any test-cloud.exe file in my Xamarin.Forms project.
This answer works, but it's pretty fragile.
The test-cloud.exe can't be located at packages/Xamarin.UITest.2.X.X/tools in projects that uses the old project structure (projects that use packages.config). For new projects (new .csproj formats), there is no such file in the path of the project. The only way I found to make it work on AppCenter is to use it from the NuGet package cache (/Users/vsts/.nuget/packages/xamarin.uitest/2.X.X)
Kudos to AppCenter Agents for helping me to resolve this. 2 things were required as indicated below:
Agent Anvesh says
Hi there, Thanks for the details, So seems like you are using a nuget as a PackageReference in your project(this means that there will be no package folder in your project, packages will be there at user profile).
So when you are trying to run the test as part of the app center build. Then in the shell script used the --uitest-tools-dir value as below
/Users/vsts/.nuget/packages/xamarin.uitest/2.2.6/lib/tools
So I modified my above script to add the below:
--uitest-tools-dir /Users/vsts/.nuget/packages/xamarin.uitest/2.2.6/tools \
Agent Shawn says
So I added the below
msbuild $APPCENTER_SOURCE_DIRECTORY/MyApp.Mobile.UITestProject.csproj
I've cloned the following Github repo to bootstrap my NativeScript application.
https://github.com/mgechev/angular-seed
I now want to run to the following command to add a toast message plugin.
tns plugin add nativescript-toast
However, I get the following error when I run the command.
No project found at or above 'C:\src\angular-seed' and neither was a --path specified.
I've tried running the command from the directory with the package.json file and the "src/client" directory as well.
Does anyone know what I'm doing wrong?
This repository https://github.com/mgechev/angular-seed support only Angular.
You should be using this repository Angular seed advanced
https://github.com/NathanWalker/angular-seed-advanced
To install the plugin:
cd nativescript && tns plugin add nativescript-toast
I've been trying to convert and deploy one of our node.js apps into a lambda function and have been having some problems with the node_modules dependencies - saying that it can't find certain modules. I started by creating a package.json, npm install the dependencies locally then copy the node modules folder up to lambda.
For instance I have a project that requires sequelize and convict and have been getting errors saying that it cannot find the moment module as a sub-dependency. I see that moment is included in the root of my node_modules but it was not included in the sub folder under the sequelize module.
However, this project runs fine locally. What is the difference in lambda and what's the best practice for deploying a somewhat long list of node modules with it - just a copy of the node_modules folder? On some of the other simpler projects I have, the small amount of node_modules can be copied up with no problems.
{
"errorMessage": "Cannot find module 'moment'",
"errorType": "Error",
"stackTrace": [
"Function.Module._resolveFilename (module.js:338:15)",
"Function.Module._load (module.js:280:25)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)",
"VERSION (/var/task/node_modules/sequelize/node_modules/moment-timezone/moment-timezone.js:14:28)",
"Object. (/var/task/node_modules/sequelize/node_modules/moment-timezone/moment-timezone.js:18:2)",
"Module._compile (module.js:456:26)",
"Object.Module._extensions..js (module.js:474:10)",
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)"
]
}
I resolved this by uploading all from a zip file which contains all the data I need for my lambda function.
you can just create your project in your local machine and make all the changes that you need then the file you are going to zip should have this same structure and also see that there is an option to load your code from a zip file.
This sounds to me like an issue caused by different versions of npm. Are you running the same version of nodejs locally as is used by Lambda (ie. v0.10.36)?
Depending on the version of npm you're using to install the modules locally, the node_modules directory's contents are laid out slightly differently (mainly in order to de-duplicate things), and that may be why your dependencies can't find their dependencies in Lambda.
After a bit of digging, it sounds like a clean install (ie. rm your node_modules directory and run npm install) might clean things up for you. The reason why is that it seems that npm doesn't install sub-dependencies if they're already present at the top level (ie. you installed moment before sequelize, etc).