How to investigate "Cannot find module X" coming from browserified bundles? - gulp

Desperate mode: Tried many different configs and all failed. I have a browserified + babelified bundle called videomail-client.js here:
https://github.com/binarykitchen/videomail-client/tree/develop/dist
The package.json's main entry of that package is pointing to this file.
Now, when I require() that package from another project within and browserify it, then I see this error from the gulp task using browserify:
[16:26:32] Error: Cannot find module './keys' from '/home/michael-heuberger/code/videomail.io/node_modules/videomail-client/dist'
at /home/michael-heuberger/code/videomail.io/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
at load (/home/michael-heuberger/code/videomail.io/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/home/michael-heuberger/code/videomail.io/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /home/michael-heuberger/code/videomail.io/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:152:21)
Hmnmm, sounds complicated? Let me rephrase. Package videomail-client is browserified. Another project, videomail.io, is requiring it and browserifying all together over again with other packages. That's there it fails.
On a side note, when I run standalone examples using videomail-client.js, it works fine.
I think the problem is that browserify can't resolve the ./keys file. But it should be included in the browserified videomail-client.js package and resolved from there. How can I tell browserify to resolve it the correct way?
Suggestions welcome how I can investigate and fix this best. Thanks!!

The solution has two steps: use browserify's standalone option and the gulp-derequire package. It works now.

This sounds a lot like a problem I ran into a few years ago (and yes, it is tough to describe :) )
I never got an answer but maybe you'll have better luck. The solution I eventually went with was to not attempt to re-browserify already-browserified libraries; I ended up just concatenating it in and minifying the whole bundle afterwards.

Related

Json Simple dependency Issue

So I have been trying to import JSON Simple (https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1)
I am also using Visual Studio Code. So I have added the dependency in my pom.xml file, but it still wont find my imports. Do I have to add soemthing to my module-info? (fixed a different issue for me) I tried requires com.json.simple; or requires com.googlecode.json.simple; but I get the cannot be resolved to a module error. Also my project is a javafx Application, that implements server socket networks (JSON exchage).
Im at a complete los here on what to do...
Thanks for your help.
So after a lot of trial and error, i have finally fixed it. Instead of vs code I used IntelliJ and added the dependencies there. Its impotant to note, that after every import I had to restart intelliJ also make sure to press the icon as mentioned in this tutorial https://www.jetbrains.com/help/idea/work-with-maven-dependencies.html#maven_import_dependency.

Need to understand gulp

I am new to gulp and i am getting object expected gulp error, but found solutions as rename file to gulfile.js
1) Need to understand every project has only one gulp file thats gulpfile.js? If i need to define more than one then how to and what will be the file name.
2)My requirement is to concatenate more than one less(convert to css) & js file into one and then apply it to index.html
3) I am using express to create gulp project structure. is this standard way? if no then how do i?
4) everytime i create gulp skeleton, do i need to install all packages again for every project?
Any references from where can learn gulp from basic.
I think one of the reasons you're getting downvoted is that on SO each question should be one question. This should really be four separate questions. Another reason is you haven't provided any of your code - add code (the { } icon) and include your gulpfile.js and your package.json.
1a) Yes, it has to be called gulpfile.js
1b) If you search SO and google for "multiple gulpfiles" you'll get a lot of solutions. If none of them work for you, let us know what you tried and what went wrong. But just so you know, it's better to start with just one gulpfile - it can be hard to get multiple gulpfiles working correctly, and using just one will help you learn gulp.
2) you'll need to use gulp-less and gulp-concat to turn multiple LESS files into one CSS file, and gulp-concat again to turn multiple js files into one.
3) You can use express, but you don't have to do. It depends what you're doing, and we have no idea what you're doing.
4) Not sure what you mean by "gulp skeleton". If you mean "Do I need to run npm install for every new project, yes you do.
5) Google "learn gulp"
6) If an image could just be text, it's better to just include the text.
If you need to, open new specific questions. For more on writing a great SO question, see https://stackoverflow.com/help/how-to-ask

How do you resolve references to gulp.src().pipe() in webstorm 10

This is a tooling question, so I'm not sure if it's appropriate for stack overflow. I'm using gulp in WebStorm 10 to concatenate my .js files into a dist folder. In my gulpfile.js, WebStorm is warning me that gulp.src(...).pipe() can not be resolved.
I've added the gulp-util typescript community map file to the libraries list in settings, which is the only place a function called pipe() exists that I can find in node_modules.
I've also confirmed that the gulp-util library is being used to try to resolve references in gulpfile.js. It's the only warning I have left in my app and I'd sure love to get it resolved.
I posted a similar question on the Webstorm site and got the following answer:
to resolve pipe open ’Settings | 'languages & Frameworks | JavaScript
| Libraries’ and choose ’Node.js Core Modules’
https://disqus.com/home/discussion/jetbrains/using_gulp_task_runner/?utm_source=reply&utm_medium=email&utm_content=read_more#comment-2240193852
In the end of 2019 faced the same issue but in PHPStorm.
i got the "Unresolved function or method pipe()" and
the "Unresolved function or method require()" error messages in PHPStorm.
Downloading the #types/gulp library in PHPStorm resolved both issues.
I had same problem and enabling Node.js Core didn't help.
For me solution was to delete whole .idea directory and import project from scratch. Be careful this will remove all your project settings.
This option helped me. All I did, was install node.d.ts from DefinitelyTyped on GitHub.
The answer is from a similar question:
https://stackoverflow.com/a/39415394/4637577

Sails.js asset management and referencing

Sorry for the noob question but I'm trying to start up a new application with Sails and include my assets. I'm using Bower to manage my packages for things like Bootstrap and JQuery. I had a read of this question and added a .bowerrc file which is now installing my Bower components to /assets.
I'm now confused as to how I should proceed to add these files into my project. It seems as though I can't just do a <script> tag in the header as I'm used to because it's giving me a file not found. Reading through the sails documentation it seems like Grunt should be creating a .tmp/public/assets folder in my project, but whenever I run sails lift and go to .tmp/ there is nothing in there.
I also read in the documentation that I should be using some kind of asset injection, I tried adding this to my HTML and it seems like it doesn't do anything.
My other question is around how I go about referencing images in my HTML. Obviously I can't just do something like src='assets/images/image.png, how should I go about this? Is there something really obvious that I'm missing?
Sails use grunt tasks to do lot of things during lift and build. You can get much better look how everything work if you take some time and check what is inside Gruntfile.js from root of your sails project.
About your specific question here is some information:
- from sails docs: "In order to take advantage of asset injection, minification, and concatenation you must put your assets in folder under assets/linker". This exactly mean that everything what you will put inside assets/linker directory will be affected by grunt tasks during lift. It mean that all files/directories from linker will be copy to .tmp/public and also some of that files will be processed before saved to .tmp/public.
- About adding tags. If you take a look at Gruntfile.js you will find this variables: var cssFilesToInject = [...] and var jsFilesToInject = [...] which contain files that will be automatic added to layout header during sails lift.
- About your 'other question', yes you can do something like 'src='linker/images/image.png' if you move that files to linker directory (assets/linker).
I hope this help :).

Msbuild running in Jenkins target calling HgPull fails with HgProcessException: The command <hg.exe> is not available

I am porting over an MSBuild script from CCnet to run in Jenkins. The MSBuild project is used to create a deployment package. I would rather have Jenkins drive this process itself but that's a longer term aim.
The problem i am having is (as in the title) when we try and use the HgPull target, from the MSBuild mecurial task (http://msbuildhg.codeplex.com/) we get the error message
HgProcessException: The command hg.exe is not available [Path to project]
I have seen on the project web site that someone solved it by adding the LibraryLocation proeprty to the target but that seems to have made no difference. My target currently looks like this:
Target Name="UpdateSources">
<HgPull
LibraryLocation="C:\Program Files\TortoiseHg\hg.exe"
Force="true"
Update="true"
LocalPath="$(SourcePath)"
/>
<HgUpdate
LibraryLocation="C:\Program Files\TortoiseHg\hg.exe"
Clean="true"
LocalPath="$(SourcePath)"
/>
I'm rather at a loss. Please let me know if you need any more information added to this post to solve this issue. I'm really quite new to MSBuild so really not sure where to start investigating this.
EDIT:
One thing i forgot to mention was that i have tried running the MSbuild command in a console window on the build server and still get the same result. This is really odd given it works fine in CCNet, what magic is CCNet doing to make this command work?
This is now resolved, unfortunately i'm not sure what changes i made to correct these. I believe it may have been down to path separators and whether they where trailing or not in another part of the config file. It does so annoy me with the lack of resilience/consistency between applications where you need to specify paths with/without trailing slashes.
Just a thought, but try adding 'C:\Program Files\TortoiseHg' to your system path. Maybe CCNet has it specified somewhere that Jenkins doesn't have access to.
Also, just for sanity's sake, verify that hg.exe actually exists at that location.