mulesoft / osprey

Generate Node.JS API middleware from a RAML definition
Other
431 stars 65 forks source link

Webpack 4 Error: ENOENT: no such file or directory, scandir '//grant' #175

Open robinComa opened 5 years ago

robinComa commented 5 years ago

Hello,

I'm trying to build my bundle with webpack and I have this issue :

fs.js:904
  return binding.readdir(pathModule._makeLong(path), options.encoding);
                 ^

Error: ENOENT: no such file or directory, scandir '//grant'
    at Object.fs.readdirSync (fs.js:904:18)
    at Object.<anonymous> (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:87772:4)
    at Object.<anonymous> (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:87807:30)
    at __webpack_require__ (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:20:30)
    at Object.<anonymous> (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:87695:18)
    at __webpack_require__ (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:20:30)
    at Object.NODE_ENV (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:87461:13)
    at __webpack_require__ (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:20:30)
    at Object.<anonymous> (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:128:16)
    at __webpack_require__ (/Users/robincomadelperier/Documents/Workspace/airbus-helicopters/webtek-api/dist/bundle.js:20:30)

My main.ts is really simple :

import * as osprey from 'osprey';
import * as express from 'express';
import * as path from 'path';

const app = express();

const printableError = (e) => {
    return `
${e.code} (${e.path} Li ${e.range.start.line}, Col ${e.range.start.column}) : 
${e.message}
`;
}

console.log(path.join(__dirname, 'assets', 'api.raml'))

osprey.loadFile(path.join(__dirname, 'assets', 'api.raml'), {})
    .then((middleware: any) => {
        app.use(middleware)

        app.use(function (err: any, req: Request, res: Response, next: Function) {
            console.error(`Error: ${err.message}`);
        })

        app.listen(3000);
    })
    .catch((err: any) => {
        console.error(`Error in the RAML of JSON SCHEMAS types :`);
        err.parserErrors.forEach((e) => {
            console.log(printableError(e));
        });
    });

It seems to be the import of osprey, I try const osprey = require('osprey') but same error. Any Ideas ?

robinComa commented 5 years ago

Same for me ... Any update ?

robinComa commented 5 years ago

Haha 9 month latter I have the same issue with another project 🤣🤣🤣

robinComa commented 5 years ago

webpack-node-externals to remove it from the webpack build

jstoiko commented 4 years ago

Thanks for the pointer @robinComa. Feel free to submit a PR.