aurelia / cli

The Aurelia 1 command line tool. Use the CLI to create projects, scaffold components, and bundle your app for release.
MIT License
407 stars 133 forks source link

ENOENT error when bundling on github repository with npm dependencies #185

Closed ben-girardet closed 6 years ago

ben-girardet commented 8 years ago

I've tried to include the github repository UDST/vizicities in a freshly aurelia-cli created project:

npm install UDST/vizicities --save

Then I added the package in aurelia_project/aurelia.json :

     {
        "name": "vendor-bundle.js",
        "prepend": [
          "node_modules/bluebird/js/browser/bluebird.core.js",
          "scripts/require.js"
        ],
        "dependencies": [
          "aurelia-binding",
          "aurelia-bootstrapper",
          "aurelia-dependency-injection",
          "aurelia-event-aggregator",
          "aurelia-framework",
          "aurelia-history",
          "aurelia-history-browser",
          "aurelia-loader",
          "aurelia-loader-default",
          "aurelia-logging",
          "aurelia-logging-console",
          "aurelia-metadata",
          "aurelia-pal",
          "aurelia-pal-browser",
          "aurelia-path",
          "aurelia-polyfills",
          "aurelia-route-recognizer",
          "aurelia-router",
          "aurelia-task-queue",
          "aurelia-templating",
          "aurelia-templating-binding",
          {
            "name": "text",
            "path": "../scripts/text"
          },
          {
            "name": "aurelia-templating-resources",
            "path": "../node_modules/aurelia-templating-resources/dist/amd",
            "main": "aurelia-templating-resources"
          },
          {
            "name": "aurelia-templating-router",
            "path": "../node_modules/aurelia-templating-router/dist/amd",
            "main": "aurelia-templating-router"
          },
          {
            "name": "aurelia-testing",
            "path": "../node_modules/aurelia-testing/dist/amd",
            "main": "aurelia-testing",
            "env": "dev"
          },
          "vizicities"
        ]
      }

And finally I ran the au run --watch command. This produces the following error:

{ uid: 10,
  name: 'writeBundles',
  branch: false,
  error: 
   { Error: ENOENT: no such file or directory, open '/web/project/src/THREE.js'
       at Error (native)
       at Object.fs.openSync (fs.js:634:18)
       at Object.fs.readFileSync (fs.js:502:33)
       at Object.exports.readFileSync (/web/project/node_modules/aurelia-cli/lib/file-system.js:38:13)
       at amodroTrace.fileRead (/web/project/node_modules/aurelia-cli/lib/build/bundled-source.js:83:31)
       at Object.context.fileRead (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:176:18)
       at Object.context.load (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:357:30)
       at Object.Module.load (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:832:29)
       at Object.Module.fetch (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:822:66)
       at Object.Module.check (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:854:30)
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/web/project/src/THREE.js',
     moduleTree: [ 'vizicities' ],
     fileName: '/web/project/node_modules/vizicities/dist/vizicities.js' },
  duration: [ 9, 90495281 ],
  time: 1466672451428 }
{ uid: 2,
  name: '<series>',
  branch: true,
  error: 
   { Error: ENOENT: no such file or directory, open '/web/project/src/THREE.js'
       at Error (native)
       at Object.fs.openSync (fs.js:634:18)
       at Object.fs.readFileSync (fs.js:502:33)
       at Object.exports.readFileSync (/web/project/node_modules/aurelia-cli/lib/file-system.js:38:13)
       at amodroTrace.fileRead (/web/project/node_modules/aurelia-cli/lib/build/bundled-source.js:83:31)
       at Object.context.fileRead (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:176:18)
       at Object.context.load (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:357:30)
       at Object.Module.load (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:832:29)
       at Object.Module.fetch (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:822:66)
       at Object.Module.check (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:854:30)
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/web/project/src/THREE.js',
     moduleTree: [ 'vizicities' ],
     fileName: '/web/project/node_modules/vizicities/dist/vizicities.js' },
  duration: [ 9, 422931251 ],
  time: 1466672451455 }
{ uid: 1,
  name: '<series>',
  branch: true,
  error: 
   { Error: ENOENT: no such file or directory, open '/web/project/src/THREE.js'
       at Error (native)
       at Object.fs.openSync (fs.js:634:18)
       at Object.fs.readFileSync (fs.js:502:33)
       at Object.exports.readFileSync (/web/project/node_modules/aurelia-cli/lib/file-system.js:38:13)
       at amodroTrace.fileRead (/web/project/node_modules/aurelia-cli/lib/build/bundled-source.js:83:31)
       at Object.context.fileRead (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:176:18)
       at Object.context.load (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:357:30)
       at Object.Module.load (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:832:29)
       at Object.Module.fetch (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:822:66)
       at Object.Module.check (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:854:30)
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/web/project/src/THREE.js',
     moduleTree: [ 'vizicities' ],
     fileName: '/web/project/node_modules/vizicities/dist/vizicities.js' },
  duration: [ 9, 424610568 ],
  time: 1466672451457 }
{ uid: 0,
  name: '<series>',
  branch: true,
  error: 
   { Error: ENOENT: no such file or directory, open '/web/project/src/THREE.js'
       at Error (native)
       at Object.fs.openSync (fs.js:634:18)
       at Object.fs.readFileSync (fs.js:502:33)
       at Object.exports.readFileSync (/web/project/node_modules/aurelia-cli/lib/file-system.js:38:13)
       at amodroTrace.fileRead (/web/project/node_modules/aurelia-cli/lib/build/bundled-source.js:83:31)
       at Object.context.fileRead (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:176:18)
       at Object.context.load (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:357:30)
       at Object.Module.load (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:832:29)
       at Object.Module.fetch (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:822:66)
       at Object.Module.check (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:854:30)
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/web/project/src/THREE.js',
     moduleTree: [ 'vizicities' ],
     fileName: '/web/project/node_modules/vizicities/dist/vizicities.js' },
  duration: [ 9, 426637499 ],
  time: 1466672451457 }
{ Error: ENOENT: no such file or directory, open '/web/project/src/THREE.js'
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.readFileSync (fs.js:502:33)
    at Object.exports.readFileSync (/web/project/node_modules/aurelia-cli/lib/file-system.js:38:13)
    at amodroTrace.fileRead (/web/project/node_modules/aurelia-cli/lib/build/bundled-source.js:83:31)
    at Object.context.fileRead (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:176:18)
    at Object.context.load (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:357:30)
    at Object.Module.load (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:832:29)
    at Object.Module.fetch (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:822:66)
    at Object.Module.check (eval at <anonymous> (/web/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:9), <anonymous>:854:30)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/web/project/src/THREE.js',
  moduleTree: [ 'vizicities' ],
  fileName: '/web/project/node_modules/vizicities/dist/vizicities.js' }

Am I doing something wrong or is this a CLI issue ?

EisenbergEffect commented 8 years ago

Probably, both. I doubt that is the correct configuration for that library. I don't know without looking at it. I can investigate this further but probably not until next week. In the mean time, see if anyone has used this with require.js or system.js and how they set that up. If you post that info here, I can try to help quicker probably.

ben-girardet commented 8 years ago

Thanks @EisenbergEffect

I suspect that this library has issues of its with modules dependencies (as mentioned here for example: https://github.com/UDST/vizicities/issues/84).

The issue I mention above comes from the dependencies to THREE.JS. I've been able to fix this issue by adding the following to aurelia.json

"three", // this includes the three library installed as dependency to vizicity
{
  "name": "THREE", // adding this help the module loader to load this package when doing an import with the name THREE in capital. Seems to provide sort of an alias name
  "path": "../node_modules/three",
  "main": "three"
},

However now I get a similar issue for another dependency called TweenLite (which is part of another npm package (gsap). I've manually installed gsap:

npm install gsap --save

And tried to do the same trick to provide an alias but this time :

"gsap", // loading the package
{
  "name": "TweenLite", // try the trick to create an alias for the TweenLite import call
  "path": "../node_modules/gsap",
  "main": "src/uncompressed/TweenLite"
},

But now I get another issue (the alias trick doesn't seem to work)

{ uid: 3,
  name: 'readProjectConfiguration',
  branch: false,
  error: 
   { Error: ENOENT: no such file or directory, open 'node_modules/TweenLite/package.json'
       at Error (native)
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: 'node_modules/TweenLite/package.json' },
  duration: [ 0, 58962783 ],
  time: 1466680620724 }

Hope this helps to debug this issue. Meanwhile I wonder if there is a proper way to create "aliases" for importing library. Something similar to the map property in the config.js file that was created by jspm

EisenbergEffect commented 8 years ago

Did you install TweenLite? It says it can't find the package. What is the actual package name?

ben-girardet commented 8 years ago

TweenLite is part of the gsap package.

capture d ecran 2016-06-23 a 13 25 59

EisenbergEffect commented 8 years ago

Ok, that's the problem. You need a flat package structure for both our CLI and Webpack. So, you need to be either using NPM 3 or use a dedupe tool to flatten your node modules tree. We added a note to this in the readme the other day but you may have missed it or not quite understood the implications. I recommend you update to npm 3.

ben-girardet commented 8 years ago

You're right I don't quite understand the implications. I understand that the gsap package seems to be designed in a non-conventional way. I am using npm 3.9.5 so this doesn't seem to be the solution.

I will look into what "dedupe" means and see if I find a solution.

EisenbergEffect commented 8 years ago

You mean that gsap is included directly in there. I see. I think we probably need to make some improvements to our code to handle the scenario where there's no package.json. I'm converting this to a bug. Can you provide drop a zip on this issue that contains the project, minus the node module folder, so I can just npm install it and test?

ben-girardet commented 8 years ago

Sure.

npm install
au run --watch

on this project will reproduce the issue.

projet.zip

EisenbergEffect commented 8 years ago

Perfect. I'll take a look later today. CLI is still pretty alpha...we think it will be nice once we work out a few of these issues ;) Thank you for your patience.

fopsdev commented 8 years ago

dang, running into the same issue whilst trying to include aurelia-api just want to know if there is already a solution to this?

EisenbergEffect commented 8 years ago

Take a look at the updated readme, in the section on 3rd party libraries and see if the new options available there will get these libraries working for you.

Alexander-Taran commented 6 years ago

no activity since July 2016