I'm using a gulpfile.js generated by yeoman's gulp-webapp generator and modified slightly by me to fit my needs. For some reason I keep running into an issue when I try to run the build process(default task). The error is thrown during the 'html' task and most of the error references are in `node_modules\gulp-useref\index.js'.
Here is the error output:
stream.js:94
throw er; //Unhandled stream in pipe.
TypeError: path must be a string
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at Transform.<anonymous> (C:\dev\project\node_modules\gulp-useref\index.js:54:44)
at Array.forEach (native)
at Transform.<anonymous> (C:\dev\project\node_modules\gulp-useref\index.js:50:31)
at Array.forEach (native)
at Transform.<anonymous> (C:\dev\project\node_modules\gulp-useref\index.js:41:36)
at Array.forEach (native)
at Transform._transform (C:\dev\project\node_modules\gulp-useref\index.js:38:23)
at Transform._read (C:\dev\project\node_modules\gulp-useref\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:184:10)
at Transform._write (C:\dev\project\node_modules\gulp-useref\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:172:12)
Here is the HTML task:
gulp.task('html', ['styles', 'scripts'], function () {
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
return gulp.src(['app/**/*.html','app/**/*.php'])
.pipe($.useref.assets())
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.csso())
.pipe(cssFilter.restore())
.pipe($.useref.restore())
.pipe($.useref())
.pipe(gulp.dest('dist'))
.pipe($.size());
});
Short answer: TypeError: path must be a string means that there is an issue with the link/script paths. useref can't find the the file or directory you are pointing it to.
Long answer:
There were two issues I ran into.
The link/script paths needs to be relative to the gulpfile or have an alternate directory to search.
<!-- build:css /styles/main.css -->
<link href="app/styles/base.css">
<link href="app/styles/article.css">
<!-- endbuild -->
OR
<!-- build:css(app) /styles/main.css -->
<link href="/styles/base.css">
<link href="/styles/article.css">
<!-- endbuild -->
The yeoman gulpfile uses multiple alt directories which requires you to put them inside curly braces like this:
<!-- build:css({.temp,app}) /styles/main.css --> Works
But if you only have one alt directory and you leave it in the curly braces it will throw an error.
<!-- build:css({app}) /styles/main.css --> TypeError: path must be a string
This is because it is reading the path as C:\path\to\project\{app}\styles\style.css. This seems like odd behavior to me. I would think that it would iterate through the directories listed in the braces regardless of the length.
Related
Please help...I am trying to get openPGP.js working in an existing ASP.Net MVC Web Application.
I first started by adding the following html script tags:
<script src="#Url.Content("~/Scripts/openpgp.min.js")"></script>
<script src="#Url.Content("~/Scripts/openpgp.worker.min.js")"></script>
and I got this error on loading my page:
ReferenceError: importScripts is not defined
So I did some research and added RequireJS to my page, like so:
<script data-main='#Url.Content("~/Scripts/openpgp.min.js")' src="#Url.Content("~/Scripts/require.js")"></script>
Then in the event handler in which I intend to run my decryption logic, I have the following code:
async function decryptBBRecording(commId) {
var openpgp = require(['openpgp']);
await openpgp.initWorker({ path: 'openpgp.worker.js' }) // set the relative web worker path
...
...
...
}
and it is on that "await" line that I am getting
TypeError: openpgp.initWorker is not a function
I'm thinking this is because I have not loaded the openpgp.worker.min.js file. But when I do so via script tag, I get the following errors:
ReferenceError: importScripts is not defined
and when I do so via require(["#Url.Content("~/Scripts/openpgp.worker.min.js")"]); I get this:
Error: Script error for "openpgp"
ReferenceError: importScripts is not defined
Please can you provide me with guidance on how to get this working?
Answer provided here.
You don't have to include openpgp.worker.min.js on the page directly. You also shouldn't need require.js and the call to require. Just include openpgp.min.js on the page, it will globally define openpgp, and then call openpgp.initWorker as you are doing.
When trying to save the PDF file, the following stack trace occurs and the file is not downloaded:
TypeError: Object expected
at API.save (http://localhost:8080/applications/lib/jspdf/jspdf.debug.js:3648:11)
at Anonymous function (http://localhost:8080/applications/js/<my_custom_js_file>.js:288:12)
at Anonymous function (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:158:482)
at e (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:45:442)
at Anonymous function (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:48:300)
Also tried with a simple example and had the same results:
var doc = new jsPDF();
doc.text("hello", 20, 20);
doc.save("table.pdf");
IE does not support native Promise. Therefore, the initialization script fails at line 12016 of Version 1.5.3:
SCRIPT5009: 'Promise' is undefined
jspdf.debug.js (12016,5)
Afterwards, the script is no longer initializing the required context.
A fix should be a 3rd party promise library - I have solved it by including the following resources before including jspdf.debug.js:
<script type="text/javascript" src="/applications/lib/ie-promise/es6-promise.js"></script>
<script type="text/javascript" src="/applications/lib/ie-promise/es6-promise#4/dist/es6-promise.auto.js"></script>
Normally Dart is connected to HTML by means of this code:
<script type="application/dart" src="script.dart"></script>
<script src="packages/browser/dart.js"></script>
By running Build, IntellijIdea transforms the first line into <script src="script.dart.js"> and eliminates the second line, OK. But there are some problems to me:
After Build file has been created, my indentation is broken.
Google PageSpeed Insight test says "Too much http requests", or something like that.
I solved the problem this way. No Build file anymore, I use Dart2js + Terminal to create script.dart.js. As to the HTML code, I've written this little thing below instead.
<script type="application/dart" src="script.dart" id="dart-script"></script>
<script>
(function() {
if (navigator.userAgent.indexOf('(Dart)') === -1) {
var dartScript = document.querySelector('#dart-script');
dartScript.type = 'application/javascript';
dartScript.src = 'script.dart.js';
}
})();
</script>
It works very well. What do you think of it?
I haven't heard of any such problems with the Dart script tags.
Using the transformer of https://pub.dartlang.org/packages/dart_to_js_script_rewriter
removes the Dart script tag which is only required by browsers that support Dart directly, which is only Dartium, which is not supposed to be used to access the web (only for development purposes), therefore for deployment this script tag is irrelevant.
Dart plugin is the same in IntelliJ IDEA, WebStorm and other JetBrains' IDEs. And it doesn't do anything with your source code on build, it only calls pub build as if you ran it from command line (assume you are talking about 'Pub: build' action in context of pubspec.yaml file).
I'll stop here my delirium with this new polyvalent code of my own.
<script>
(function() {
var elem = document.createElement('script');
document.querySelector('body').appendChild(elem);
if (navigator.userAgent.indexOf('(Dart)') === -1) {
elem.type = 'application/javascript';
elem.src = 'script.dart.js';
}
else {
elem.type = 'application/dart';
elem.src = 'script.dart';
}
})();
</script>
Thank you for applause, that's all folks!
new here, so I hope this question is adequate.
We have a an ant build file that runs a task to preprocess html template files. Here is the snippet from the build file.
<!-- Process the templates. -->
<fmpp sourceroot="on-board" outputroot="${template.dir}" removeExtensions="TMPL" >
<include name="**/*.TMPL" />
<data expandProperties="true">
DEBUG: true
CONTENT_REVISION: r${Revision}
CONTENT_PACK: vzw-${TRACK}
</data>
</fmpp>
I am working with polymer now and want to convert our build to use gulp because fmpp (and yuicompressor) are choking on some of the js files in polymer due to reserved words. I found a gulp-freemarker plugin that I thought might be able to substitute for fmpp. However, 1) I am not sure of this, and 2) I can not seem to get anything working with gulp-freemarker including their example code from github.
Here is my gulpfile:
var gulp = require('gulp');
var freemarker = require("gulp-freemarker");
gulp.task('myfmpp', function()
{
return gulp.src("./app/en_US/hello.json")
.pipe(freemarker(
{
viewRoot: "app/en_US/",
options: {}
}))
.pipe(gulp.dest("./www"))
});
This seems to run OK - no errors - but there is no apparent output. Since I am a bit new to this stuff, I may not know what I should be looking for...
Anyway, my ultimate goal is to achieve the same preprocessing result from gulp-freemarker as with ant/fmpp. Can anyone help answer this and point me in the right direction?
Thanks!
Ken
I have been trying to automate the renumbering of pdb-files using a numbering server called Abnum. They state: To number a structure you must pass parameters in POST format and use enctype="multipart/form-data". It does work for a single sequence, but uploading the pdb-file(plain-text file) remains a problem.
My code:
import requests
rel_path = "PDB_mono"
rel_path2 = "1A5F.pdb"
i = os.path.abspath(__file__)
g = os.getcwd()
mypath = os.path.join(g,rel_path)
mypath = os.path.join(mypath,rel_path2)
print mypath
url = 'http://www.bioinf.org.uk/cgi-bin/abnum/abnumpdb.pl?plain=1&pdb=1A5F.pdb&scheme=-a&output=-l'
files = {'file': open('1A5F.pdb', 'rb')}
r=requests.post(url, files={'file': open(mypath)}).content
print r
Myfile:
mypath =F:\Leuven\Python\PDB_mono\1A5F.pdb
Response:
<html>
<head>
<title>AbNum results</title>
<link rel='stylesheet' href='/bo.css' />
</head>
<body>
<h1>Abnum: PDB numbering</h1>
<h3>There was an error in your submission</h3>
<pre>
Either the PDB file you specified did not exist, or contained no ATOM records
</pre>
<p>Click the browser "Back" button to return to the form and correct your error.</p>
</body>
</html>
</body>
</html>
I'm using Windows 7, python 2.7.
I would really appreciate a response, or at least some pointing in the right direction
example PDB file:
pdb file
You can download it on the right as a text file. It's a simple file containing coordinates of atoms