grunt-contrib-copy: Unable to read file (Error code: ENOENT)
Hi,
since I’m very to new to Grunt I’m sure the problem here is on my side, but I simply can’t figure it out. Here’s my directory structure:
.
├── _build
└── Gruntfile.js
└── css
├── img
└── src
└── images
├── img-01.jpg
└── img-02.jpg
I now want all the images from ./css/src/images
to be copied to ./css/img
. I think the closest I got was using this code:
copy: {
main: {
expand: true,
files: [
{
cwd: '../css/src/images/',
src: ['**'],
dest: '../css/img'
}
]
}
}
Which resulted in the --verbose
output:
Running "copy:main" (copy) task
Verifying property copy.main exists in config...OK
Files: , img-01.jpg, img-02.jpg -> ../css/img
Options: processContent=false, processContentExclude=[]
Creating ../css/img
Copying img-01.jpg -> ../css/img
Reading img-01.jpg...ERROR
Warning: Unable to read "img-01.jpg" file (Error code: ENOENT). Use --force to continue.
Aborted due to warnings.
The file img-01.jpg
is obviously there so I don’t really get the error message. Can anyone give me a hint here?
Thanks in advance, Tobi
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 22 (6 by maintainers)
@papatoob it appears you need to you need expand:true when using cwd
Ok, this is pretty funny, I was running into this issue, forgetting I had solved it, googled the problem, ended up here and saw my own answer.
I faced the same issue when my image file was actually a shortcut. It worked when I copied the original file.
Just wanted to add that this idiosyncrasy cost me a bit of time and almost made me look for other grunt add-ons. Can I suggest that README be updated with this fact ie.,
cwd:'path/'
only works w/expand:true
?Update: saw #161 - fine if that was the update. I do still want to emphasize that if you have grunt newbies coming (like me) it might still be helpful for this be documented here - just my 2c. Thanks for building!