vanjacosic / gulp-asset-manifest

gulp plugin for adding generated assets to a manifest file
MIT License
7 stars 4 forks source link

ENOENT on writeFileSync #10

Closed omnibs closed 9 years ago

omnibs commented 9 years ago

I've posted this on stackoverflow also, so anyone able to help can get some points there.

I'm using the code on this site to write a gulp file for a Windows aspnet + angularjs app.

I'm running only styles for now, and when I run gulp I get:

Error: ENOENT, no such file or directory 'C:\project\build\manifest-debug.json'
at Error (native)
at Object.fs.openSync (fs.js:502:18)
at Object.fs.writeFileSync (fs.js:1103:15)
at writeManifestFile (C:\project\node_modules\gulp-asset-manifest\index.js:30:8)
at resetManifestFile (C:\project\node_modules\gulp-asset-manifest\index.js:51:5)
at module.exports (C:\project\node_modules\gulp-asset-manifest\index.js:76:5)
at getManifest (C:\project\Gulpfile.js:97:12)
at Gulp.<anonymous> (C:\project\Gulpfile.js:126:15)
at module.exports (C:\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\project\node_modules\gulp\node_modules\orchestrator\index.js:273:3)

Looking at C:\project\node_modules\gulp-asset-manifest\index.js:30:8 I see:

fs.writeFileSync(filename, JSON.stringify(data));

So I ran this on node's REPL:

fs.writeFileSync('C:\\project\\build\\manifest-debug.json', 'hi');

And the file was created correctly.

I tried running gulp again with an existing file and got the exact same error.

I added a console.log(filename); before line 30 on index.js and I got:

./build/manifest-debug.json

So I ran fs.writeFileSync('./build/manifest-debug.json', 'hi'); on REPL from the same folder and it worked too.

gulp-asset-manifest is being called with these options:

{ bundleName: 'scripts',
  includeRelativePath: true,
  manifestFile: './build/manifest-debug.json',
  log: true,
  pathPrepend: undefined,
  pathSeparator: '/' }

Not sure what's going on.

I'm running everything with UAC disabled and on a command prompt with admin rights.

omnibs commented 9 years ago

The cause was fs.writeFileSync requires the path to exists, and during the execution of the gulpfile in question, ./build was nonexistent.

Not an issue in the end.