My application runs fine when I run using ng serve but when i use tns run android --bundle or tns run android then it gives me following exception.
Searching for devices...
Preparing project...
Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
- options[0] misses the property 'patterns'. Should be:
[non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
- options[1] misses the property 'patterns'. Should be:
[non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
- options[2] misses the property 'patterns'. Should be:
[non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
at validate (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\schema-utils\dist\validate.js:96:11)
at new CopyPlugin (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\copy-webpack-plugin\dist\index.js:24:30)
at module.exports (C:\Ambiente PGE\workspace\ui\app-mobile\webpack.config.js:304:13)
at handleFunction (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\prepareOptions.js:23:13)
at prepareOptions (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\prepareOptions.js:9:5)
at requireConfig (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\convert-argv.js:136:14)
at C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\convert-argv.js:142:17
at Array.forEach (<anonymous>)
at module.exports (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\convert-argv.js:140:15)
at C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\cli.js:241:39
at Object.parse (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\node_modules\yargs\yargs.js:567:18)
at C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\cli.js:219:8
at Object.<anonymous> (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\cli.js:538:3)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Executing webpack failed with exit code 1.
I created the project as follows:
ng new my-mobile
ng add #nativescript/schematics
I have already updated cli, npm and nativescript to the latest version
The same happened to me and When I try to edit webpack.config.js it works for me just replace the lines
new CopyWebpackPlugin([
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.jpg" } },
{ from: { glob: "**/*.png" } },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
to be
new CopyWebpackPlugin({
patterns: [
{ from: "fonts/**", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
{ from: "**/*.{jpg,png}", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
]
}, { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
and do not forget to add fonts folder if you do not have one
Related
The error below showing after executing in jenkins:
`Your configFile threw an error from: /var/lib/jenkins/workspace/PluginsUI/cypress.config.js
The error was thrown while executing your e2e.setupNodeEvents() function:
Error: Cannot find module 'node-xlsx'
Require stack:
/var/lib/jenkins/workspace/PluginsUI/cypress/plugins/index.js
/var/lib/jenkins/workspace/PluginsUI/cypress.config.js
/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_require_async_child.js
/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/require_async_child.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/var/lib/jenkins/workspace/PluginsUI/cypress/plugins/index.js:26:16)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at setupNodeEvents (/var/lib/jenkins/workspace/PluginsUI/cypress.config.js:11:14)
at /var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_plugins.js:118:14
at tryCatcher (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
at RunPlugins.load (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_plugins.js:115:9)
at RunPlugins.runSetupNodeEvents (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_plugins.js:276:10)
at EventEmitter. (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_require_async_child.js:185:22)
at EventEmitter.emit (node:events:513:28)
at process. (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/util.js:33:22)
at process.emit (node:events:513:28)
at emit (node:internal/child_process:939:14)`
I'm trying to execute the test case in cypress on jenkins pipelin configuration:
pipeline{
agent any
parameters{
string(name: 'SPEC', defaultValue: "cypress/e2e/1.Gateway/MqttGateway.cy.js", description: "Enter the script path that you want to execute")
choice(name: 'BROWSER', choices: ['chrome', 'edge', 'firefox'], description: "Choose the browser where you want to execute your scripts")
}
options{
ansiColor('xterm')
}
stages{
stage('Building'){
steps{
echo "Building the application"
}
}
stage('Testing'){
steps{
sh "npm i"
sh "npx cypress run --browser ${BROWSER} --spec ${SPEC}"
}
}
stage('Deploying'){
steps{
echo "Deploy the application"
}
}
}
post{
always{
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'cypress/report', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: '', useWrapperFileDirectly: true])
}
}
}
I've already installed cypress and I once successfully open it and run some example test cases. I don't know why when I try to open it again with command npx cypress open in vscode it says
Cypress Configuration Error
This is the stack trace:
Error: Cannot find module 'cypress'
Require stack:
- C:\Users\janna\Documents\Miftah's folder\Learn\Cypress\gitRepo\ngx-cypress-test\cypress.config.js
- C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js
- C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\require_async_child.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#cspotcode\source-map-support\source-map-support.js:679:30)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\janna\Documents\Miftah's folder\Learn\Cypress\gitRepo\ngx-cypress-test\cypress.config.js:1:26)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadFile (C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js:89:14)
at EventEmitter. (C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js:116:38)
at EventEmitter.emit (node:events:527:28)
at EventEmitter.emit (node:domain:475:12)
You can fix that file with watchForFileChanges: false,
const { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
watchForFileChanges: false,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
I'm following this book: https://github.com/manfredsteyer/schematics-sample
When I execute my schematics
schematics .:my-comp
I get the following error:
An error occured:
Error: Schematic "my-comp" cannot resolve the factory.
at NodeModulesEngineHost.createSchematicDescription (/home/.../.npm-global/lib/node_modules/#angular-devkit/schematics-cli/node_modules/#angular-devkit/schematics/tools/file-system-engine-host-base.js:174:19)
at SchematicEngine.createSchematic (/home/.../.npm-global/lib/node_modules/#angular-devkit/schematics-cli/node_modules/#angular-devkit/schematics/src/engine/engine.js:219:38)
at CollectionImpl.createSchematic (/home/.../.npm-global/lib/node_modules/#angular-devkit/schematics-cli/node_modules/#angular-devkit/schematics/src/engine/engine.js:69:29)
at NodeWorkflow.execute (/home/.../.npm-global/lib/node_modules/#angular-devkit/schematics-cli/node_modules/#angular-devkit/schematics/src/workflow/base.js:99:38)
at main (/home/.../.npm-global/lib/node_modules/#angular-devkit/schematics-cli/bin/schematics.js:202:24)
at Object.<anonymous> (/home/.../.npm-global/lib/node_modules/#angular-devkit/schematics-cli/bin/schematics.js:293:5)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
This is part of my factory:
export default function myComp(options: IFlexComponentOptions): Rule {
return (host: Tree, context: SchematicContext) => {
console.log("options before sanatize", options);
...
return rule(host, context);
};
}
my collectyion.json
{
"$schema": "../node_modules/#angular-devkit/schematics/collection-schema.json",
"schematics": {
"my-comp": {
"description": "This schematics generate an Angular Component on the current module or in an specified one",
"factory": "./my-comp/index#myComp"
}
}
}
I had the same problem, from export default function myComp remove the default. And it should work. I follow the same book. Lots of incompatibilities.
For those who doesn't use default and has the same issue, please check the hash name versus the function name in the index file.
I have a component that loads styles like this. The css directory is somewhere else; here it is being used as a Webpack alias.
import 'css/components/PromptText';
// ...
class PromptText extends React.Component {
// ...
}
Here is my webpack.config.json:
var path = require('path');
module.exports = {
entry: './src/index.jsx',
output: {
path: 'dist',
filename: 'app.bundle.js',
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
}, {
test: /\.json/,
exclude: /node_modules/,
loader: 'json',
}, {
test: /\.scss/,
exclude: /node_modules/,
loaders: ['style', 'css', 'sass'],
}],
},
resolve: {
alias: {
css: 'css', // <-- Alias here
},
root: path.resolve(__dirname),
extensions: ['', '.js', '.jsx', '.scss'],
},
};
Now, I have a test like this for Mocha:
import PromptText from '../../src/components/PromptText';
describe('PromptText', () => {
it('should display words');
});
When Mocha imports the component, it also tries to load the CSS component. There are two problems with this:
The css directory has been aliased. Mocha needs to know where the alias points. To fix this, I have installed the babel-plugin-webpack-alias package, with the following .babelrc:
{
"presets": ["es2017", "react", "stage-0"],
"env": {
"test": {
"plugins": [
["webpack-alias", {"config": "webpack.config.js"}]
]
}
}
}
CSS can't be imported by Mocha, so it needs to be ignored. I use the ignore-styles package and invoke Mocha as mocha --compilers js:babel-core/register --require ignore-styles.
Despite having done these two things, I get the following error when trying to run tests:
(cd data && make)
make[1]: Nothing to be done for `all'.
NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register --require ignore-styles \
$(find test -type f -name 'test*.js')
module.js:341
throw err;
^
Error: Cannot find module 'css'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/waleed/Workspace/js/steno/src/components/PromptText.jsx:2:1)
at Module._compile (module.js:413:34)
at loader (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:146:5)
at Object.require.extensions.(anonymous function) [as .jsx] (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:156:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/waleed/Workspace/js/steno/test/components/testPromptText.js:2:1)
at Module._compile (module.js:413:34)
at loader (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:146:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:156:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at /Users/waleed/Workspace/js/steno/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/waleed/Workspace/js/steno/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/Users/waleed/Workspace/js/steno/node_modules/mocha/lib/mocha.js:485:10)
at Object.<anonymous> (/Users/waleed/Workspace/js/steno/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:148:18)
at node.js:405:3
make: *** [test] Error 1
For some reason, the css alias isn't being resolved. However, this error only happens sometimes, unpredictably. In order to consistently recreate this error, I have to set BABEL_DISABLE_CACHE=1 in the environment.
How can I get my Mocha test to correctly import and ignore the CSS file?
In order to fix this, I switched from the babel-plugin-webpack-alias to the babel-plugin-webpack-aliases package, and update my .babelrc to use it:
{
"presets": ["es2017", "react", "stage-0"],
"env": {
"test": {
"plugins": [
["webpack-aliases", {"config": "webpack.config.js"}]
]
}
}
}
I also always run mocha with BABEL_DISABLE_CACHE=1 set in the environment. (I think this is undoing the damage that babel-plugin-webpack-alias did; it may not be necessary on every run if that package was never used.)
I'm trying to run a Protractor Test using Angular 2 and Webpack
Partial Webpack config:
resolve: {
extensions: ['', '.ts', '.js', '.scss', '.css']
},
module: {
loaders: [
// TypeScript
{ test: /\.ts$/, loader: 'ts-loader'},
// SCSS
{ test: /\.scss$/, exclude: /node_modules/, loaders: ['raw-loader', 'sass-loader']}
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(true)
]
My home.component.ts
import { Component, Injectable } from '#angular/core';
#Component({
selector: 'home',
styles: [require('./home.component.scss')],
template: `<h4 class="page-home">Home</h4>`
})
#Injectable()
export class Home {}
And my home.component.scss
.page-home {
color: blue;
}
And my E2E:
require('../server');
describe('App', () => {
beforeEach(() => {
browser.get('/');
});
it('should have a title', (done) => {
let subject = browser.getTitle();
subject
.then((data) => {
let result = 'test';
expect(data).toEqual(result);
done();
});
});
it('should definitely pass', () => {
expect(true).toEqual(true);
});
});
I run the server and everything comes up as expected. When I run my E2E tests I get the following error:
[14:42:47] I/hosted - Using the selenium server at http://hub.browserstack.com/wd/hub
[14:42:47] I/launcher - Running 1 instances of WebDriver
[14:43:03] E/launcher - Error: /app/src/app/home/home.component.scss:1
(function (exports, require, module, __filename, __dirname) { .page-home {
^
SyntaxError: Unexpected token .
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at home.component.ts:5:12
at Object.<anonymous> (home.component.ts:9:21)
[14:43:03] E/launcher - Process exited with error code 100
npm info lifecycle cnd-app#1.0.0~protractor: Failed to exec protractor script
npm ERR! Linux 3.19.0-59-generic
npm ERR! argv "/usr/local/bin/node" "/app/node_modules/.bin/npm" "run" "protractor"
npm ERR! node v6.2.0
npm ERR! npm v3.9.2
npm ERR! code ELIFECYCLE
npm ERR! cnd-app#1.0.0 protractor: `protractor protractor.conf.js`
npm ERR! Exit status 100
It seems like protractor uses require different than how WebPack treats it.Is there a config for this or anything I am missing?
** Update **
I am able to resolve the issue. I have a typescript register causing conflict in the protractor.conf.js.