Ionic2 ionic native camera - ionic2
I get build error using ionic-native module as it always gives me the following error
Error: ./src/pages/admin-home/admin-home.ts Module not found: Error: Can't resolve 'ionic-native' in
'E:\Work\myBabyFeed\myBabyFeed\src\pages\admin-home' resolve 'ionic-native' in
'E:\Work\myBabyFeed\myBabyFeed\src\pages\admin-home' Parsed request is a module using description file:
E:\Work\myBabyFeed\myBabyFeed\package.json (relative path: ./src/pages/admin-home) Field 'browser' doesn't
contain a valid alias configuration after using description file: E:\Work\myBabyFeed\myBabyFeed\package.json
(relative path: ./src/pages/admin-home) resolve as module looking for modules in
E:\Work\myBabyFeed\myBabyFeed\node_modules using description file:
E:\Work\myBabyFeed\myBabyFeed\package.json (relative path: ./node_modules) Field 'browser' doesn't contain a
valid alias configuration after using description file: E:\Work\myBabyFeed\myBabyFeed\package.json (relative
path: ./node_modules) using description file:
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\package.json (relative path: .) no extension Field
'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native is not a file .ts Field 'browser' doesn't contain a
valid alias configuration E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.ts doesn't exist .js Field
'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.js doesn't exist .json Field 'browser' doesn't
contain a valid alias configuration E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.json doesn't
exist as directory existing directory using path:
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index using description file:
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\package.json (relative path: ./index) no extension
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index doesn't exist .ts Field 'browser' doesn't
contain a valid alias configuration E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.ts doesn't
exist .js Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.js doesn't exist .json Field 'browser' doesn't
contain a valid alias configuration E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.json
doesn't exist [E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.ts]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.js]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.json]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.ts]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.js]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.json] # ./src/pages/admin-home/admin-home.ts
13:0-46 # ./src/app/app.module.ts # ./src/app/main.ts
Error: ./src/pages/admin-home/admin-home.ts
Module not found: Error: Can't resolve 'ionic-native' in 'E:\Work\myBabyFeed\myBabyFeed\src\pages\admin-home'
resolve 'ionic-native' in 'E:\Work\myBabyFeed\myBabyFeed\src\pages\admin-home'
Parsed request is a module
using description file: E:\Work\myBabyFeed\myBabyFeed\package.json (relative path: ./src/pages/admin-home)
Field 'browser' doesn't contain a valid alias configuration
after using description file: E:\Work\myBabyFeed\myBabyFeed\package.json (relative path: ./src/pages/admin-home)
resolve as module
looking for modules in E:\Work\myBabyFeed\myBabyFeed\node_modules
using description file: E:\Work\myBabyFeed\myBabyFeed\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: E:\Work\myBabyFeed\myBabyFeed\package.json (relative path: ./node_modules)
using description file: E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\package.json (relative path: .)
no extension
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native is not a file
.ts
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.json doesn't exist
as directory
existing directory
using path: E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index
using description file:
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\package.json (relative path: ./index)
no extension
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native\index.json doesn't exist
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.ts]
[E:\Work\myBabyFeed\myBabyFeed\node_modules\ionic-native.js]
I have updated the packages file with latest version of ionic-native but still get the error.
anyone can help please
Related
configuring app.yaml handler for static image files
I have been trying to configure my app.yaml in the Google Cloud Platform. I would like to achieve two things: redirect all URLs (except images) to the main index.html in the root folder. For example, example.com/abcd should be redirected to example.com. load any image requests from the folder named "mypics". Here is my existing app.yaml file. runtime: python27 api_version: 1 threadsafe: true handlers: # image files - url: /(.*\.(bmp|gif|ico|jpeg|jpg|png)) static_files: mypics/\1 upload: mypics/(.*\.(bmp|gif|ico|jpeg|jpg|png)) # URL redirect - url: /(.*) static_files: index.html upload: index.html I have managed to get the redirects working. However, the images are not being loaded. I have reversed the order of the handlers, which does not seem to make a difference. If I try to load the image directly, I get the following error: Error: Not Found The requested URL /mypics/Diamond.png was not found on this server. Thanks for your help.
I suspect it has to do with how you specify the path to your images in your template files (i.e. html files). Let me explain with the result of the test I did on my machine Previously, Folder structure Project Root static images image_1.png image_2.png css app.yaml - url: /static static_dir: static Code in index.html file was < img src="/static/images/image_1.png" alt="Image 1" >. The above worked (i.e. images were properly displayed) Then I changed to your code - url: /(.*\.(bmp|gif|ico|jpeg|jpg|png)) static_files: mypics/\1 upload: mypics/(.*\.(bmp|gif|ico|jpeg|jpg|png)) The images were no longer displayed. I also tried - url: /static/(.*\.(bmp|gif|ico|jpeg|jpg|png)) static_files: mypics/\1 upload: mypics/(.*\.(bmp|gif|ico|jpeg|jpg|png)) but the images were still not displayed. I then went back and modified the routing in app.yaml to - url: /static/images/(.*\.(bmp|gif|ico|jpeg|jpg|png)) static_files: mypics/\1 upload: mypics/(.*\.(bmp|gif|ico|jpeg|jpg|png)) The change here is that I specified the full path I used in my index.html i.e. static/images/ and the images got displayed again
NamedTemporaryFile triggers SuspiciousFileOperation
In django version 3.2.12, I try to download an image for which I have an URL and store it inside an ImageField. It looks like this: def load_image_from_url(self): image_file = NamedTemporaryFile(delete=True, dir='project/media') with urlopen(self.extra_large_url) as uo: assert uo.status == 200 image_file.write(uo.read()) image_file.flush() image = File(image_file) self.image.save(image.name, image) When I create the NamedTemporaryFile, the path generated is an absolute path. In django.core.files.utils, it get blocked in this condition: if allow_relative_path: # Use PurePosixPath() because this branch is checked only in # FileField.generate_filename() where all file paths are expected to be # Unix style (with forward slashes). path = pathlib.PurePosixPath(name) if path.is_absolute() or '..' in path.parts: raise SuspiciousFileOperation( "Detected path traversal attempt in '%s'" % name ) With a dir argument set for the NamedTemporaryFile, the issue remains even if the folder is a subdirectory of the project. Is there a better solution than doing this: self.image.save(os.path.basename(image.name), image)
How do I configure alembic.ini path correctly?
When I run any alembic commands, I get the following error: FAILED: No config file 'alembic.ini' found, or file has no '[alembic]' section According to the documentation, I need to set my path so I did. I'm running WSL Ubuntu 18. Am I setting the path wrong? I run the commands in my flask project's top directory: ~/microblog$ My alembic file structure is: ~/microblog/ - migrations/ -- __pycache__/ -- versions/ -- alembic.ini -- env.py -- README -- script.py.mako alembic.ini # A generic, single database configuration. [alembic] script_location = home/acanizales1/microblog/migrations/alembic # template used to generate migration files # file_template = %%(rev)s_%%(slug)s # set to 'true' to run the environment during # the 'revision' command, regardless of autogenerate # revision_environment = false # Logging configuration [loggers] keys = root,sqlalchemy,alembic ... the rest below are configured correctly ... Thank you.
SwiftLint: Exclude file for specific rule
I'm trying to do something like this in my .swiftlint.yml file: force_cast: severity: warning # explicitly excluded: - Dog.swift I have this code and I don't like the force_try warning I'm getting for it: let cell = tableView.dequeueReusableCellWithIdentifier(Constants.dogViewCellReuseIdentifier, forIndexPath: indexPath) as! DogViewCell I want to suppress the warning for this file by excluding this file from the rule. Is there a way to do that ?
Well, if you don't want some specific rules to be applied to a specific file you can use the technique mentioned by #Benno Kress. For that you need to add a comment in your swift file as given below. The rules will be disabled until the end of the file or until the linter sees a matching enable comment: // swiftlint:disable <rule1> YOUR CODE WHERE NO rule1 is applied // swiftlint:enable <rule1> It is also possible to skip some files by configuring swiftlint. add a ".swiftlint.yml" file in the directory where you'll run SwiftLint. Add the following content to exclude some files. Lets say file1, file2 ... etc excluded: - file1 - file2 - folder1 - folder1/ExcludedFile.swift To disable some rules completely add the following to the same ".swiftlint.yml" file. disabled_rules: # rule identifiers to exclude from running - colon - comma - control_statement for more information, refer the following links. https://swifting.io/blog/2016/03/29/11-swiftlint/ https://github.com/realm/SwiftLint#disable-rules-in-code
You can write // swiftlint:disable force_cast at the beginning of the file in which you want to supress the warning for this rule. It gets disabled until the end of the file or until you add the line // swiftlint:enable force_cast. Source: https://github.com/realm/SwiftLint#disable-rules-in-code
I just get rid with force_cast Step 1: cd path-to-your-project Step 2: touch .swiftlint.yml Step 3: open .swiftlint.yml and add the rule disabled_rules: # rule identifiers to exclude from running - force_cast Reference - https://github.com/realm/SwiftLint#disable-rules-in-code
Configure SwiftLint by adding a .swiftlint.yml file from the directory you'll run SwiftLint from. Here is the complete set of options you can use in your .swiftlint.yml file disabled_rules: # rule identifiers to exclude from running - colon - comma - control_statement opt_in_rules: # some rules are only opt-in - empty_count # Find all the available rules by running: # swiftlint rules included: # paths to include during linting. `--path` is ignored if present. - Source excluded: # paths to ignore during linting. Takes precedence over `included`. - Carthage - Pods - Source/ExcludedFolder - Source/ExcludedFile.swift - Source/*/ExcludedFile.swift # Exclude files with a wildcard analyzer_rules: # Rules run by `swiftlint analyze` (experimental) - explicit_self # configurable rules can be customized from this configuration file # binary rules can set their severity level force_cast: warning # implicitly force_try: severity: warning # explicitly # rules that have both warning and error levels, can set just the warning level # implicitly line_length: 110 # they can set both implicitly with an array type_body_length: - 300 # warning - 400 # error # or they can set both explicitly file_length: warning: 500 error: 1200 # naming rules can set warnings/errors for min_length and max_length # additionally they can set excluded names type_name: min_length: 4 # only warning max_length: # warning and error warning: 40 error: 50 excluded: iPhone # excluded via string identifier_name: min_length: # only min_length error: 4 # only error excluded: # excluded via string array - id - URL - GlobalAPIKey reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown) Reference: github.com/realm/SwiftLint#disable-rules-in-code
You can add a new .swiftlint.yml file to the excluded folder and override rules there: project_root/.swiftlint.yml: opt_in_rules: force_unwrapping .. and other rules and in project_root/your_excluded_folder/.swiftlint.yml disabled_rules: - force_unwrapping Then force_unwrapping will not be applied to your_excluded_folder and all subfolders Config file from subfolder will "override" rules in the root config file. This is useful for example for the unit tests folder
Maybe this is a better approach: guard let cell = tableView.dequeueReusableCellWithIdentifier(Constants.dogViewCellReuseIdentifier, forIndexPath: indexPath) as? DogViewCell else { return UITableviewCell() }
Have custom Find*.cmake file find different libraries depending on visual studio build type (Debug/Release)
I am creating a few C++ libraries in a project (solution in VS terminology) that needs to be used by two other projects. For this I created a FindDQSAnalyticsInfra.cmake file which is as follows: # DQSAnalyticsInfra # ----- # Find the path to DQSAnalyticsInfra header files and libraries # # DEFINES # ------ # DQSINFRA_ROOT - Root of the DQSAnalyticsInfra project # DQSINFRA_INCLUDE_DIR - DQSAnalyticsInfra include directory # DQSINFRA_LIBRARIES - Libraries required to link DQSAnalyticsInfra # DQSINFRA_FOUND - Confirmation set(DQSINFRA_LIBRARIES_LIST Utils Actor gtest) find_path(DQSINFRA_INCLUDE_DIR Actor/Actor.h Utils/Log.h gtest/gtest/gtest.h ${DQSINFRA_ROOT}/include ) foreach(search_lib ${DQSINFRA_LIBRARIES_LIST}) find_library(DQSINFRA_LIB NAMES ${search_lib} PATHS ${DQSINFRA_ROOT}/lib/Release #The problem is here ) set(DQSINFRA_LIBRARIES ${DQSINFRA_LIBRARIES} ${DQSINFRA_LIB}) if(DQSINFRA_LIB) unset(DQSINFRA_LIB CACHE) set(DQSINFRA_FOUND TRUE) else(DQSINFRA_LIB) set(DQSINFRA_FOUND FALSE) break() endif(DQSINFRA_LIB) endforeach(search_lib) if(DQSINFRA_INCLUDE_DIR AND DQSINFRA_LIBRARIES AND DQSINFRA_FOUND) set(DQSINFRA_FOUND TRUE) message(STATUS "Found DQSAnalyticsInfra. ") message(STATUS "Include Path: ${DQSINFRA_INCLUDE_DIR}") message(STATUS "Libraries ${DQSINFRA_LIBRARIES}") else(DQSINFRA_INCLUDE_DIR AND DQSINFRA_LIBRARIES AND DQSINFRA_FOUND) set(DQSINFRA_FOUND FALSE) message(STATUS "DQSAnalyticsInfra not found.") endif(DQSINFRA_INCLUDE_DIR AND DQSINFRA_LIBRARIES AND DQSINFRA_FOUND) mark_as_advanced(DQSINFRA_INCLUDE_DIR DQSINFRA_LIBRARIES) This file works fine. The issue is that in the find_library command used in this file, I am hardcoding the path as ${DQSINFRA_ROOT}/lib/Release. This mean that I cannot use this file to link to Debug builds (I have to manually change the file to use ${DQSINFRA_ROOT}/lib/Debug). Any idea on how this can be fixed.Thanks.
Use debug and optimized keywords that can be specified for target_link_libraries: find_library(DQSINFRA_LIB_DEBUG NAMES ${search_lib} PATHS ${DQSINFRA_ROOT}/lib/Debug ) find_library(DQSINFRA_LIB_RELEASE NAMES ${search_lib} PATHS ${DQSINFRA_ROOT}/lib/Release ) set(DQSINFRA_LIBRARIES optimized ${DQSINFRA_LIB_RELEASE} debug ${DQSINFRA_LIB_DEBUG})