DOJO include files a directory back - javascript

I have dojo files in resources/js/dojo1.6/dojo/dojo.js
I have another file here resources/js/pages/file1.js
This file requires another file which is located at resources/js/folder/file2.js
This is how I am including it dojo.require('folder.file2');
So these three folder are in hirarchy
dojo1.6, pages and folder
When I run application
I got the following error
File not found: /resources/js/dojo1.6/folder/file2.js
How can I overcome this error.

You need to tell Dojo where your modules can be found, relative to dojo.js, using dojo.registerModulePath:
dojo.registerModulePath("pages", "../../pages");
dojo.registerModulePath("folder", "../../folder");
See http://dojotoolkit.org/reference-guide/dojo/registerModulePath.html for a more detailed explanation.

Related

Why is eleventy trying to parse a file in a passthrough copy?

I added a "scripts" folder as a passthrough copy to my Eleventy site and installed some npm dependencies inside it for scripts to be run on the page load.
So my .eleventy.js has some lines like this:
eleventyConfig.addPassthroughCopy("img");
eleventyConfig.addPassthroughCopy("scripts");
eleventyConfig.addPassthroughCopy("css");
But when I run npx eleventy, I get a build error that says,
Language does not exist: sh
Problem writing Eleventy templates: (more in DEBUG output)
> Having trouble rendering liquid (and markdown) template ./scripts/wb-service-worker/node_modules/bs-fetch/README.md
Why is it trying to "render liquid" in a passthrough copy? (I thought the whole point of passthrough copies is it doesn't try to parse them.) How do I get it to stop?
addPassthroughCopy will copy the files through without parsing, but if the file is also in the input directory, eleventy will process it in its normal way too.
You should keep the assets that you want to be passthrough-copied in a seperate folder to the src files that you are inputting to eleventy for processing.
See these docs for more help:
Input Directory
Ignoring Files
Passthrough's handling of input files

Building vuejs application doesn't build relative file references correctly

When running : npm run build it generates a html file containing references to the generated scripts. However, the link looks like this :
/static/js/manifest.2ae2e69a05c33dfc65f8.js
There is no period at the beginning so I get errors in the console saying the files can't be found. When I manually add the period, it works fine. Where does this get generated from ?
Thanks to #Thoomas in the comments I figured out how to solve this issue.
In the index.js file under the config directory, I had to change the build.assetsPublicPath from '/' to './'.
This now builds with the correct relative paths.

Node.js - Error: Cannot find module 'config/chgpass'

I created the files following the tutorial (http://dataops.co/android-login-registration-system-with-node-js-and-mongodb/), but unfortunately the error is shown like in the image.
I'm new to node.js and to this kind of programming.
PS.: All of the other files that are referred in the tutorial are right, and the chgpass.js is in the target folder.
Code from the file that requests the chgpass.js file AND the tree from the folder (open with Word and select MS-DOS):
http://www.mediafire.com/download/w283nsjuuj9j794/File-Folder.txt
As your config folder is inside of node_modules folder, thus use:
var chgpass = require('config/chgpass');
Explanation:
In tutorial config folder is inside node_modules that way you can directly access it using require('config/chgpass')
But if you put outside of node_modules then you have to give the complete path of the folder from the location you are requiring it. That is in your case: require('../config/chgpass')

locating path of a file in meteorjs

I have a project in meteorjs that is using the nodes filesystem to read file, but I am not able to locate the file to be read.
My file Location
Server
- startup
- app.load.coffee
- myfileToBeRead.txt
My try in app.load.coffee
fs = Npm.require('fs')
console.log fs.readFileSync 'server/startup/myfileToBeRead.txt'
I am not able to read the file as it says
Error: ENOENT, no such file or directory 'server/startup/myfileToBeRead.txt'
I think since meteor merges everything in a js file, I have to add full path to the file.
I have tried other paths aswell (with the full path, without the full path). Can you point me out to the correct direction here?
Thank you
Well with the answer from David, I also found that I could do this with the assets/app directory of the project. All I had to do was add the file to a directory named private. This would also help me write to a file inside the directory aswell.
fs = Npm.require('fs')
console.log fs.readFileSync "assets/app/myfileToBeREad", 'utf8'
if the file should be checked in
This is the easy case - just place the file in your private directory and access it with the assets api. For more examples, see my blog post on exactly this subject.
if the file should exist somewhere else on the server
Use an absolute path to a directory not associated with your project, e.g. /tmp or /home/foo/bar. Directories inside of a meteor project get jumbled up after you bundle and deploy your app, so their existence can't be counted on. Using your example above it should work if you do something like:
var fs = Npm.require('fs');
fs.readFileSync('/tmp/myfileToBeRead.txt');

api.add_files is missing a file in Meteor package

I'm adding three files for the client in my Meteor package like so:
api.add_files([
'lib/client/newsletter_banner.html',
'lib/client/newsletter_banner.css',
'lib/client/templates.js'
], ['client']);
newsletter_banner.html defines a template which is not available when I load the site. If I look through the sources in Devtools, I can see that the CSS and JS files are available, but the HTML file is not. Why is this? I've confirmed that the filename is correct and even changed it thinking that name might be unavailable to me for whatever reason, but the file is still not included.
Html files are loaded by the templating package, so you need to add it to your package as well:
api.use(['templating', 'spacebars', 'ui'], 'client');

Categories