systemjs: Error resolving .js files from filesystem
I have the following build script:
let path = require('path');
let Builder = require('systemjs-builder');
const pkg = require('./package.json');
const deps = pkg.dependencies;
function getPaths(){
return Object.map(deps, function(k,v){
return require.resolve(k);
});
}
let builder = new Builder(__dirname, {
paths: getPaths()
});
let src = path.resolve(__dirname + '/browser-polyfills/dest/all-core-and-npm.js');
let dest = path.resolve(__dirname + '/dist/outfile.js');
builder
.bundle(src, dest)
.then(function () {
console.log('Build complete');
})
.catch(function (err) {
console.log('Build error');
console.log(err);
});
I get this error:
Build error
{ Error on fetch for node_modules/ascii-table/ascii-table at file:///Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman/node_modules/ascii-table/ascii-table
Loading ascii-table
Loading browser-polyfills/dest/all-core-and-npm.js
Error: ENOENT: no such file or directory, open '/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman/node_modules/ascii-table/ascii-table'
at Error (native)
originalErr:
{ Error: ENOENT: no such file or directory, open '/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman/node_modules/ascii-table/ascii-table'
at Error (native)
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman/node_modules/ascii-table/ascii-table' } }
I confirmed that require.resolve() will always return a .js file, even for ascii-table, and this file exists on my filesystem. It seems clear that SystemJS should be looking for:
/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman/node_modules/ascii-table/ascii-table.js
but instead, SystemJS is erroneously looking for:
/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman/node_modules/ascii-table/ascii-table
It’s looking for a file without the .js extension…
this is such a fundamental problem (I have seen the same with RequireJS), why does this happen?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (7 by maintainers)
@ORESoftware I think you’re just after
main: "ascii-table.js", or just use something like:For this error, it is likely due to
ascii-tabledoes not havepackage.json/mainspecified. https://github.com/unional/domture#usageTry to do the following:
Likely a duplication of https://github.com/systemjs/systemjs/issues/1603
In the meantime, I am going to go cry for awhile LOL