having problem getting started with grunt-ts.
I've got one src folder in my project folder:
\src
test.ts
test2.ts
After compilation, i have:
\src
test.js
test.js.map
test.ts
test2.js
test2.js.map
test2.ts
Actually, this is exactly what i want .... but ..
then the task aborts with an error:
Arguments to path.resolve must be strings
My grunt config section is:
ts: {
dev: {
src: ["src/*.ts"]
}
},
Versions and stuff: i today installed grunt-ts. Any ideas???
Arguments to path.resolve must be strings
That error is really generic. PS: I think the error is in grunt-contrib-watch
PS PS: can you share the project?
This is the error source btw : https://github.com/joyent/node/blob/master/lib/path.js#L116 the question is: what is calling path.resolve incorrectly? I'd like to debug that.
Related
i am having an issue with webpack and my css file. Whenever i run "npm start", i get this error :
ERROR in ./ticker.css 1:0
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
I read that it requires a loader for css files however i have installed 'style-loader' and 'css-loader' but apparently it still won't work. Any ideas ?
Here is :
webpackconfig, package file, ticker.css file
Thanks guys !
I tried to delete and recreate the node_modules directory, use raw loader, change the loaders order.
Turned out my node.js version wasn't up to date which caused some conflicts with some packages. Think about updates guys. :)
Here is my grunt-sass declaration.
sass: {
site: {
options: {
implementation: 'dart-sass',
style: 'compressed',
noCache: true
},
dist: {
files: {
'dist/css/jk.css' : 'src/sass/jk.scss'
}
}
}
},
When I run grunt, or grunt triggers on the watch clause, I get this output.
Running "sass:site" (sass) task
The file "dist/css/jk.css" is never created. I get no other output from Grunt. If I run sass from the command line, the file completes without any trouble.
I'm not sure why it's failing, as it's failing silently. If nothing else, I'd love to know how to enable verbose failures.
UPDATE. Tried running grunt with -v, this is the output.
Running "sass:site" (sass) task
Verifying property sass.site exists in config...OK
File: [no files]
Options: precision=10, implementation="dart-sass", style="compressed", noCache
undefined
It looks like I'm not declaring the files correctly. I'm quite certain the paths are correct. If I run sass from the command line with the same paths it succeeds as expected.
Adding -v or --verbose has returned errors. I'm still not able to compile sass, but the issue of the missing errors is resolved.
I'm using skipper to receive the files, sharp to resize (and save) and fs unlink to remove the old image. But I got a very weird error this time that concerns me a lot:
error: ** Grunt :: An error occurred. **
error:
Aborted due to warnings.
Running "copy:dev" (copy) task
Warning: Unable to read "assets/images/users/c8e303ca-1036-4f52-88c7-fda7e01b6bba.jpg" file (Error code: ENOENT).
error: Looks like a Grunt error occurred--
error: Please fix it, then restart Sails to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run npm install if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the .tmp directory?
error: e.g., (edited for privacy)/sails/.tmp ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 1000 (edited for privacy)/sails/.tmp
Grunt stopped running and to have that in production is a big NoNo... I believe that this is caused because of concurrency with fs.unlinkSync(fname). The error is also intermittent and very hard to reproduce in some machines (IO ops/sec maybe?).
I have the following controller action:
var id = 1; // for example
req.file('avatar').upload({
dirname: require('path').resolve(sails.config.appPath, 'assets/images')
}, function(err, files){
var avatar = files.pop();
//file name operations here. output is defined as the path + id + filetype
//...
sharp(avatar.fd)
.resize(800, 800)
.toFile(output, (err, info)=>{
if(err){
res.badRequest();
} else {
fs.unlinkSync(avatar.fd);
res.ok();
}
});
});
Now I've been thinking about a few solutions:
Output the new image directly to .temp
Unlink when files exists on .tmp. Explanation: Grunt already copied the old file so removing it would be safe!
But I don't know if this is some spaghetti code or even if a better solution exists.
EDIT: My solution was, as proposed by arbuthnott, wrap a controller like this:
get : function(req, res){
var filepath = req.path.slice(1,req.path.length);
//remove '/' root identifier. path.resolve() could be used
if(fs.existsSync(path.resolve(filepath))){
return res.sendfile(filepath);
} else {
return res.notFound();
}
}
I think you are on the right track about the error. You are making some rapid changes to in the assets folder. If I read your code right:
Add an image with user-generated filename to assets/images (ex cat.jpg)
Copy/resize the file to an id filename in assets/images (ex abc123.jpg)
Delete the original upload (cat.jpg)
(I don't know the details of sharp, there may be more under the hood there)
If sails is running in dev mode, then Grunt will be trying to watch the whole assets/ folder, and copy all the changes to .tmp/public/. It's easy to imagine Grunt may register a change, but when it gets around to copying the added file (assets/images/cat.jpg) it is already gone.
I have two suggestions for the solution:
One:
Like you suggested, upload your original to the .tmp folder (maybe even a custom subfolder of .tmp). Still place your sized copy into /assets/images/, and it will be copied to /.tmp/public/ where it can be accessed as an asset by the running app. But Grunt will ignore the quick add-then-delete in the .tmp folder.
Two:
Do a bit of general thinking about both what you want to include in version control, and what Grunt tasks you want to be running in production. Note that if you use sails lift --prod then Grunt watch is turned off by default, and this error would not even occur. Generally, I don't feel like we want Grunt to do too much in production, it is more of a development shortcut. Specifically, Grunt watch can use a lot of resources on a production server.
The note about version control is just that you probably want some of the contents of assets/images/ to be in version control (images used by the site, etc), but maybe not in the case of user-uploaded avatars. Make sure you have a way to differentiate these contents (subdirectories or whatever). Then they can be easily .git-ignore'd or whatever is appropriate.
Hope this helps, good luck!
I'm trying to get the default Yeoman Webapp to work with Assemble.io.
I followed this tutorial Using assemble.io with yeoman.io’s webapp Gruntfile
Got it up & running (partially), the first problem I have is that livereload isn't kicking in when changes are made to the .hbs files. When I manually refresh, I can see the changes that were made.
This is my Grunt file.
Second problem is that 'grunt build' gives me the following error:
Running "requirejs:dist" (requirejs) task
{ [Error: Error: Missing either an "out" or "dir" config value. If using "appDir" for a full project optimization, use "dir". If you want to optimize to one file, use "out".
at Function.build.createConfig ([MY DIRECTORY]/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:25109:19)
]
originalError: [Error: Missing either an "out" or "dir" config value. If using "appDir" for a full project optimization, use "dir". If you want to optimize to one file, use "out".] }
I googled around & when I add the following to requirejs:dist:options
appDir: '<%= yeoman.app %>/', dir: 'build'
Then this error is solved, but the next appears:
No "concat" targets found.
Warning: Task "concat" failed. Use --force to continue.
Versions:
Yeoman 1.0.4
Node 0.10.21
Bower 1.2.7
Grunt-cli 0.1.9
Grunt 0.4.1
Anyone seeing the problem? Thanks!
See this line in your gist. It's trying to call a task called concat in your Gruntfile, but that task doesn't exist. There may have been a change with the Yeoman webapp generator or you might have had a copy/paste issue or something. The assemble part of your Gruntfile looks fine.
I think you can remove the concat and carry on.
i created an angular application with yeoman, when i executed grunt command i got the following error
Running "karma:unit" (karma) task
WARN [config]: JASMINE is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: JASMINE_ADAPTER is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: LOG_INFO is not supported anymore.
Please use `karma.LOG_INFO` instead.
ERROR [config]: Config file must export a function!
module.exports = function(config) {
config.set({
// your config
});
};
how do i solve this error ?
It's just those two predefined terms (JASMINE and JASMINE_ADAPTER)
that should not be used any more. All you have to do is open the
config file ./config/karma.conf.js and comment out those terms and add
frameworks = ["jasmine"];.
Via Yasuhiro Yoshida
apart from #sheplu's answer, there are additional changes that need to be done in karma.conf.js, you can see it in https://gist.github.com/sivakumar-kailasam/6421378
this gist solves your problem of 'Config file must be a export a function!'
The official docs has these changes as well http://karma-runner.github.io/0.10/config/configuration-file.html