I try to create a simple multi-apps project in Ionic 4, following the ionic documentation, but it doesn't work.
https://ionicframework.com/docs/cli/configuration#multi-app-projects
My config :
Ionic : v4.12.0
Angular CLI : 7.3.8
Node : 10.15.1
npm : 6.9.0
Windows 10
What I have done :
I have created a directory “monorepo”.
In this folder, I created a file ionic.config.json and pasted in it the code below:
{
"projects": {}
}
In monorepo, I create a second directory : apps.
In this directory (with the command prompt), I write the command :
ionic start "app1" --no-deps
monorepo/ionic.config.json is correctly populated with the data:
{
"projects": {
"app1": {
"name": "app1",
"integrations": {},
"type": "angular",
"root": "apps\\app1"
}
}
}
But when I try to serve the server, it won't work.
ionic serve --project app1 return me this error message :
> ng run app1:serve --host=0.0.0.0 --port=8100
[ng] Project 'app1' could not be found in workspace.
[ng] Error: Project 'app1' could not be found in workspace.
[ng] at Workspace.getProject (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\core\src\workspace\workspace.js:93:19)
[ng] at Architect.getBuilderConfiguration (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\architect\src\architect-legacy.js:117:41)
[ng] at RunCommand.runSingleTarget (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\models\architect-command.js:160:45)
[ng] at RunCommand.runArchitectTarget (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\models\architect-command.js:201:35)
[ng] at RunCommand.run (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\commands\run-impl.js:14:25)
[ng] at RunCommand.validateAndRun (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\models\command.js:124:31)
[ng] at process._tickCallback (internal/process/next_tick.js:68:7)
[ng] at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
[ng] at startup (internal/bootstrap/node.js:283:19)
[ng] at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
[ERROR] ng has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.
When I go under the file associated with the error (workspace.js:93:19), and I do console.log, I obtain this info:
getProject(projectName) {
this._assertLoaded();
console.log("this.projectName : " + projectName); // this.projectName : app1
console.log("\n\nthis._workspace.projects : \n");
console.log(this._workspace.projects); // this._workspace.projects : app and app-e2e
const workspaceProject = this._workspace.projects[projectName];
(Values displayed are in comments).
The projectName variable seems ok. But the available project in this._workspace.projects are app and app-e2e which seem weird.
What is my problem ?
What did I miss ?
I managed to compile by replacing in the angular.json every app keyword by the name of my ionic project (here, app1).
{
"$schema": "./node_modules/#angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"defaultProject": "app1", <-- HERE
"newProjectRoot": "projects",
"projects": {
"app1": { <-- HERE
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app1", <-- NOT MANDATORY
"schematics": {},
"architect": {
"build": { ... },
"serve": {
"builder": "#angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app1:build" <-- HERE
},
...
}
I suppose that instead of putting several angular apps within one project structure you should rewrite each ionic project's angular.json
Related
I want to upload photos from the gallery but using #capacitor/core, it will open camera only. And, showing this error after installing #capacitor/camera.
[ng] ERROR in node_modules/#capacitor/camera/dist/esm/definitions.d.ts:1:13 - error TS1005: '=' expected.
[ng] 1 import type { PermissionState } from '#capacitor/core';
[ng] ~
[ng] node_modules/#capacitor/camera/dist/esm/definitions.d.ts:1:38 - error TS1005: ';' expected.
[ng] 1 import type { PermissionState } from '#capacitor/core';
[ng] ~~~~~~~~~~~~~~~~~
[ng] node_modules/#capacitor/camera/dist/esm/index.d.ts:1:13 - error TS1005: '=' expected.
[ng] 1 import type { CameraPlugin } from './definitions';
[ng] ~
[ng] node_modules/#capacitor/camera/dist/esm/index.d.ts:1:35 - error TS1005: ';' expected.
[ng] 1 import type { CameraPlugin } from './definitions';
[ng] ~~~~~~~~~~~~~~~
Here is my package.json file.
"#capacitor/android": "^2.0.1",
"#capacitor/camera": "^1.3.1",
"#capacitor/core": "2.0.1",
"#capacitor/ios": "^2.0.1",
Its a typescript error so first upgrade typescipt to latest version.
run
npm install -g typescript#latest
and then check version
tsc -v
copy the version and search typescript in package.json and paste the version.
now do
npm install
i was trying to use sonar cloud to analyse my code using azure devops pipeline
i faced this error, in Run Code Analysis task , but the step still passed in the end :
14:53:52.353 INFO: Found 1 tsconfig.json file(s): [/home/vsts/work/1/s/tsconfig.json]
##[error]14:53:52.489 ERROR: Unknown compiler option '#angular/*'.
##[debug]Processed: ##vso[task.logissue type=error;]14:53:52.489 ERROR: Unknown compiler option '#angular/*'.
##[debug]Processed: 14:53:52.489 ERROR: Unknown compiler option '#angular/*'.##vso[task.logissue type=error;]
this my tsconfig.json file
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"#angular/*": ["../node_modules/#angular/*"],
"typeRoots": [
"node_modules/#types"
],
"lib": [
"es2017",
"dom"
]
}
}
i'am able to generate the dist file.
can someone help me
Remove the offending line
"#angular/*": ["../node_modules/#angular/*"],
As the error suggests, #angular/* is not a valid compilerOption.
See also https://angular.io/guide/angular-compiler-options
Thanks for any help, getting error message "Error: Native modules for sensors not available. Did react-native link run successfully?" when running npx react-native start
npx react-native run-android gives this error: > Task :app:processDebugManifest FAILED
right after installing react-native-sensors.
Install procedure:
npx react-native init proj8
cd proj8
npm install react-native-sensors --save
npx react-native link react-native-sensors
The last command reported successful but when I went through the manual Android procedure some parts were not done as follows:
import com.sensors.RNSensorsPackage;
was in android/app/src/main/java/[...]/MainApplication.java
new RNSensorsPackage()
was not there, I added as follows:
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new RNSensorsPackage());
return packages;
}
include ':react-native-sensors'
project(':react-native-sensors').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensors/android')
were both there in android/settings.gradle
dependencies {
implementation project(':react-native-sensors')
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
I had to add implementation project(':react-native-sensors')
I don't think my code matters yet but App.js:
import React, {useState, useEffect, useRef} from 'react';
import { StyleSheet,ScrollView,SafeAreaView,Platform, View,Text } from 'react-native';
export default function App() {
var Rndr =
<Text>asdf</Text>
return Rndr
}
package.json:
{
"name": "proj8",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-sensors": "^7.0.1"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
I encountered the same problem. This occurs because react-native-sensors has a minsdk version is 17 and react-native's default minsdk version is 16 Its quite easy to solve.
Just go to android/build.gradle
Change minSdkVersion to anything above 17
Before
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
After
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 19
compileSdkVersion = 29
targetSdkVersion = 29
}
When attempting to package a nuxt component, I get the above error. I am running nuxt 2.4.5, #babel/core 7.0.0 and rollup 1.4.0.
Does anyone have any thoughts?
Thanks in advance..
npm run script:
"build:es": "rollup --config build/rollup.config.js --format es --file dist/cxl-nuxt-map.esm.js"
Command :
nr build:es
cxl-nuxt-map#1.0.0 build:es /Users/userinfo/Projects/cxl-nuxt-map rollup --config build/rollup.config.js --format es --file dist/cxl-nuxt-map.esm.js
index.js → dist/cxl-nuxt-map.esm.js...
Stack Trace:
[!] (babel plugin) Error: .sourceMap must be a boolean, "inline", "both", or undefined
index.js
Error: .sourceMap must be a boolean, "inline", "both", or undefined
at assertSourceMaps (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/validation/option-assertions.js:65:11)
at Object.keys.forEach.key (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/validation/options.js:107:5)
at Array.forEach (<anonymous>)
at validateNested (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/validation/options.js:83:21)
at validate (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/validation/options.js:74:10)
at file (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/config-chain.js:174:34)
at cachedFunction (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/caching.js:33:19)
at buildRootChain (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/config-chain.js:120:36)
at loadPrivatePartialConfig (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/partial.js:85:55)
at Object.loadPartialConfig (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/#babel/core/lib/config/partial.js:110:18)
at Object.babel.loadPartialConfig (/Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/rollup-plugin-babel/src/index.js:80:20)
at /Users/dan.mahoney/Projects/cxl-nuxt-map/node_modules/rollup/dist/rollup.js:17051:25
at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:47:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:804:11)
at internal/main/run_main_module.js:21:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cxl-nuxt-map#1.0.0 build:es: `rollup --config build/rollup.config.js --format es --file dist/cxl-nuxt-map.esm.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cxl-nuxt-map#1.0.0 build:es script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/dan.mahoney/.npm/_logs/2019-03-01T20_10_17_889Z-debug.log
Rollup.config.js:
/* rollup.config.js */
import vue from 'rollup-plugin-vue';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import replace from 'rollup-plugin-replace';
import { plugin as analyze } from 'rollup-plugin-analyzer';
export default {
input: 'index.js',
output: {
name: 'CxlNuxtMap',
exports: 'named',
},
plugins: [
postcss({
extensions: ['.css'],
runtimeHelpers: true,
exclude: 'node_modules/**',
}),
vue(),
babel({
exclude: 'node_modules/**',
}),
replace({
'process.env.INCLUDE_DEPS': JSON.stringify('false'),
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
commonjs({
namedExports: {},
}),
analyze({ stdout: true }),
],
};
Found in the problem in my .babelrc file. The offending line was:
"sourceMap": "true",
should be:
"sourceMaps": true,
I am working with Ionic 3 and Stripe.
I am seeing this error on iOS Xcode debug.
2018-07-04 16:40:49.873337-0400 TestApp[2943:7783516] CDVPlugin class
CordovaStripe (pluginName: CordovaStripe) does not exist.
2018-07-04
16:40:49.873443-0400 TestApp[2943:7783516] ERROR: Plugin
'CordovaStripe' not found, or is not a CDVPlugin. Check your plugin
mapping in config.xml.
2018-07-04 16:40:49.873527-0400
TestApp[2943:7783516] -[CDVCommandQueue executePending] [Line 142]
FAILED pluginJSON =
["CordovaStripe1777748815","CordovaStripe","setPublishableKey",["pk_test_12345678900"]]
my config.xml
<plugin name="cordova-plugin-stripe" spec="~1.5.3" />
app.module.ts
import { Stripe } from '#ionic-native/stripe';
... providers: [ ...
Stripe ] }) export class AppModule {}
> package.json "dependencies": {
> "#ionic-native/stripe": "^4.9.0",
>
> "cordova-plugin-stripe": {}
> },
> "platforms": [
> "android",
> "ios"
> ]
Any help is appreciated.
Thanks in advance
Phil
I found the answer.. This was very strange.
ionic cordova platform remove ios
ionic cordova platform add ios
npm install
exit out of xcode
restart and resign in xcode..
All seems to be working now..
Thanks
Phil