Im trying to get the body of my local Word document using mammoth and load into my current file placehodler but this error appears:
Uncaught (in promise) ReferenceError: process is not defined
at ./node_modules/path/path.js (path.js:25:1)
at webpack_require (bootstrap:24:1)
at fn (hot module replacement:61:1)
at ./node_modules/mammoth/lib/docx/docx-reader.js (docx-reader.js:4:12)
at webpack_require (bootstrap:24:1)
at fn (hot module replacement:61:1)
at ./node_modules/mammoth/lib/index.js (index.js:3:18)
at webpack_require (bootstrap:24:1)
at fn (hot module replacement:61:1)
at _callee3$ (taskpane.js:131:17)
my code:
var mammoth = require("mammoth");
async function GerarDocxHtml() {
Word.run(function (ctx) {
mammoth.convertToHtml({path: "./myfile/template.docx"})
.then(function(result){
//The generated HTML
var docxHtml = result.value;
//place holder ([docx])
var results = ctx.document.body.search("[docx]");
ctx.load(results);
return ctx.sync().then(function () {
for (var i = 0; i < results.items.length; i++) {
results.items[i].insertHtml(docxHtml, "replace");
}
});
}).done();
});
}
Can someone help?
Related
I am trying to use the '#ensdomains/eth-ens-namehash' package to hash an input.
I am using it in combination with 'pinia'.
I call on this method in Nuxt3.
This is the code:
import { defineStore } from "pinia"
import namehash from "#ensdomains/eth-ens-namehash"
import { Buffer } from 'buffer'
export const exampleMethod = defineStore('example', {
state: () => {
return{
hash: String
}
},
actions: {
method(input) {
globalThis.Buffer = Buffer
this.hash = namehash.hash(input).toString()
}
}
}
When trying to call 'method' I get the following error:
Uncaught (in promise) Error: Module "punycode" has been externalized
for browser compatibility. Cannot access "punycode.ucs2" in client
code.
I am facing problem while adding third party javascript code in my payment module in magento2.
following is my code.
define(
[
'Magento_Payment/js/view/payment/cc-form',
'jquery',
'Vendorname_Modulename/js/stsdk'
'Magento_Payment/js/model/credit-card-validation/validator'
],
function (Component, $, STDirect) {
'use strict';
return Component.extend({
defaults: {
template: 'Vendorname_Modulename/payment/module-form'
},
getCode: function() {
return 'vendor_module';
},
isActive: function() {
return true;
},
validate: function() {
STDirect.setupSDK('23842', "testnumber", 'typeofenv');
STDirect.card.createToken(number, exp_month, exp_year, ccv, function (result) {
var secretkey = '';
if(result.status==0){
secretkey = result.card.secretkey;
}
document.write(JSON.stringify(result));
alert(secretkey);
});
var $form = $('#' + this.getCode() + '-form');
return $form.validation() && $form.validation('isValid');
}
});
}
);
I have tried above code, stsdk.js is loaded in network but it gives me following error :
ReferenceError: STDirect is not defined
STDirect.setupSDK('23842', "testnumber", 'sandbox');
I have also checked by load this js file in header but same error appear.
My question is how to execute third party javascript code in define scope.
I tried with the custom javascript function after define function but it is also not callable from validate function and when I use require[] function within define function it raise error.
I appreciate any help.
native-country-picker and when I run it I got the error:
undefined is not an object NativeModules.CountryPicker.show
I tried to do these steps:
react-native upgrade
rnpm link
(after the plugin install)
and same error.
this is the country picker plugin
https://github.com/tofugear/react-native-country-picker
This is the code of the plugin:
'use strict';
import { NativeModules } from 'react-native';
var RNCountryPicker= NativeModules.CountryPicker;
var CountryPicker = {};
CountryPicker.show = function (callBack) {
NativeModules.CountryPicker.show(callBack);
};
CountryPicker.hide = function () {
RNCountryPicker.hide();
};
module.exports = CountryPicker;
And the error in the line:
NativeModules.CountryPicker.show(callBack);
undefined is not an object (evaluating '_reactNative.NativeModules.CountryPicker.show')
I'm trying to use jupyter as a backend for my system and now I play with examples from jupyter-js-api docs.
Using IKernel and INotebookSession I managed to execute simple code and get the response form kernel.
But I can's figure out how to extract the notebook itself. there's nothing like "saveNotebook()" in API. I try to execute session.renameNotebook(), it completes successfully, but no files appear in filesystem (tried different paths like "/tmp/trynote.ipynb" "trynote.ipnb" and so on...).
Here's the code, it is slightly edited example from http://jupyter.org/jupyter-js-services/ page
#!/usr/bin/env node
var jpt = require("jupyter-js-services");
var xr = require("xmlhttprequest");
var ws = require("ws");
global.XMLHttpRequest = xr.XMLHttpRequest;
global.WebSocket = ws;
// start a new session
var options = {
baseUrl: 'http://localhost:8889',
wsUrl: 'ws://localhost:8889',
kernelName: 'python',
notebookPath: 'trynote.ipynb'
};
jpt.startNewSession(options).then((session) => {
// execute and handle replies on the kernel
var future = session.kernel.execute({ code: 'print(5 * 5);' });
future.onDone = (msg) => {
console.log('Future is fulfilled: ');
console.log(msg);
};
future.onIOPub = (msg) => {
console.log("Message in IOPub: ");
console.log(msg);
};
// rename the notebook
session.renameNotebook('trynote2.ipynb').then(() => {
console.log('Notebook renamed to', session.notebookPath);
});
// register a callback for when the session dies
session.sessionDied.connect(() => {
console.log('session died');
});
// kill the session
session.shutdown().then(() => {
console.log('session closed');
});
});
Looking and ContentManager API it seems to work with already existing files, or creating new ones, but its unclear how is it bound to sessions.
More, even simplest try to use "newUntitled" function gives 404 response...
var contents = new jpt.ContentsManager('http://localhost:8889');
// create a new python file
contents.newUntitled("foo", { type: "file", ext: "py" }).then(
(model) => {
console.log(model.path);
}
);
I feel a bit disoriented with all this and would appreciate any explanations.
Thanks..
We are new to Protractor and are going through the code to better understand its functionalists and in comparison with writing tests with selenium. As an exercise we have tried to automate the angularjs home page (http://www.angularjs.org) using page objects
Our TestSpec.js file is as follows
'use strict';
var DevelopPage = require('../test_11th/Develop_pom.js');
describe('angularjs homepage', function () {
var Devpage;
beforeEach(function () {
Devpage = new DevelopPage();
});
it('Develop page should be open', function () {
Devpage.click_develop().click();
//Devpage.Api_Reference();
//Devpage.func_link();
//Devpage.search('angular');
});
});
and the page object file Develop_pom.js is as follows
'use strict';
var DevelopPage = function () {
browser.get('http://www.angularjs.org');
};
DevelopPage.prototype = Object.create({}, {
click_develop: { function ()
{ browser.driver.findElement(By.linkText("Develop")).click(); }},
Api_Reference: { function ()
{ browser.driver.findElement(By.linkText("API Reference")).click(); }},
func_link: { function ()
{ browser.driver.findElement(By.linkText("function")).click(); }},
search: { : function (txt)
{ element(by.model('q')).click().sendKeys(txt); }}
});
while running it we are encountering the error
1) Exception loading: C:\Users\kirti.vm\AppData\Roaming\npm\node_modules\protractor\test_11th\AngularSpec.js Error
Message:
SyntaxError: Unexpected token (
Stacktrace:
SyntaxError: Unexpected token (
at require (module.js:380:17)
at Object. (C:\Users\kirti.vm\AppData\Roaming\npm\node_modules\protractor\test_11th\AngularSpec.js:4:21)
Finished in 0.012 seconds
1 test, 1 assertion, 1 failure
can you please let us know what and where we are going wrong. Can we not use page objects to implement our test and call those page objects in the spec script.
You need to export the page object at the end of the file:
module.exports = DevelopPage;
Take a look at the following example if you want to see a cleaner syntax:
https://github.com/angular/protractor/blob/master/website/test/e2e/api-page.js