jvandemo / generator-angular2-library

Yeoman generator to create an Angular library
MIT License
752 stars 122 forks source link

Error: Could not resolve './directives/' from build\index.js #279

Closed nirving closed 6 years ago

nirving commented 6 years ago

When running npm run build I am getting the following

> @darkedges/framauthui@0.1.0 build C:\development\angular2\framauthui
> gulp build

[06:59:30] Using gulpfile C:\development\angular2\framauthui\gulpfile.js
[06:59:30] Starting 'clean:dist'...
[06:59:30] Finished 'clean:dist' after 255 μs
[06:59:30] Starting 'clean:tmp'...
[06:59:30] Finished 'clean:tmp' after 19 ms
[06:59:30] Starting 'clean:build'...
[06:59:30] Finished 'clean:build' after 24 ms
[06:59:30] Starting 'clean'...
[06:59:30] Finished 'clean' after 49 μs
[06:59:30] Starting 'compile'...
[06:59:30] Starting 'clean:dist'...
[06:59:30] Finished 'clean:dist' after 96 μs
[06:59:30] Starting 'copy:source'...
[06:59:30] Finished 'compile' after 11 ms
[06:59:30] Starting 'build'...
[06:59:30] Finished 'build' after 6.04 μs
[06:59:30] Finished 'copy:source' after 200 ms
[06:59:30] Starting 'inline-resources'...
[06:59:30] Finished 'inline-resources' after 140 ms
[06:59:30] Starting 'ngc'...
[06:59:33] Finished 'ngc' after 2.95 s
[06:59:33] Starting 'rollup:fesm'...
The following options have been renamed — please update your config: format -> output.format
'@angular/common/http' is imported by build\index.js, but could not be resolved – treating it as an external dependency

events.js:137
      throw er; // Unhandled 'error' event
      ^
Error: Could not resolve './directives/' from build\index.js
    at error (C:\development\angular2\framauthui\node_modules\gulp-rollup\node_modules\rollup\dist\rollup.js:170:15)
    at C:\development\angular2\framauthui\node_modules\gulp-rollup\node_modules\rollup\dist\rollup.js:18849:25
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @darkedges/framauthui@0.1.0 build: `gulp build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @darkedges/framauthui@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\NIrving\AppData\Roaming\npm-cache\_logs\2018-02-07T19_59_34_046Z-debug.log

It would seem it only likes flat file structures and not those build with directories.

In my src directory I have

total 26
drwxr-xr-x 1 NIrving 197121    0 Feb  7 17:04 components/
drwxr-xr-x 1 NIrving 197121    0 Feb  7 17:04 containers/
drwxr-xr-x 1 NIrving 197121    0 Feb  7 17:04 directives/
-rw-r--r-- 1 NIrving 197121 2093 Feb  7 16:49 index.ts
drwxr-xr-x 1 NIrving 197121    0 Feb  7 17:04 interceptors/
drwxr-xr-x 1 NIrving 197121    0 Feb  7 17:04 models/
-rw-r--r-- 1 NIrving 197121  595 Feb  7 17:03 package.json
drwxr-xr-x 1 NIrving 197121    0 Feb  7 17:04 services/
-rw-r--r-- 1 NIrving 197121  637 Feb  7 17:03 tsconfig.es5.json
-rw-r--r-- 1 NIrving 197121  322 Feb  7 17:03 tsconfig.spec.json 

and in src\directives

total 1
drwxr-xr-x 1 NIrving 197121   0 Feb  7 17:04 dynamic-field/
drwxr-xr-x 1 NIrving 197121   0 Feb  7 17:04 form-host/
-rw-r--r-- 1 NIrving 197121 198 Nov  5 05:54 index.ts
drwxr-xr-x 1 NIrving 197121   0 Feb  7 17:04 programmatic-input-fire-event/

Do I need the rollup-plugin-commonjs or rollup-plugin-node-resolve to resolve this? Any ideas?

Thanks Nicholas Irving

nirving commented 6 years ago

If i do the following

npm install rollup-plugin-commonjs

add the following to the var

  commonjs = require('rollup-plugin-commonjs');

and add

 plugins: [
        commonjs()
      ],

to rollup:fesm and rollup:umd

it returns

[19:37:35] Starting 'clean:dist'...
[19:37:35] Finished 'clean:dist' after 18 ms
[19:37:35] Starting 'clean:tmp'...
[19:37:35] Finished 'clean:tmp' after 147 μs
[19:37:35] Starting 'clean:build'...
[19:37:35] Finished 'clean:build' after 308 μs
[19:37:35] Starting 'clean'...
[19:37:35] Finished 'clean' after 21 μs
[19:37:35] Starting 'compile'...
[19:37:35] Starting 'clean:dist'...
[19:37:35] Finished 'clean:dist' after 155 μs
[19:37:35] Starting 'copy:source'...
[19:37:35] Finished 'compile' after 12 ms
[19:37:35] Starting 'build'...
[19:37:35] Finished 'build' after 4.53 μs
[19:37:35] Finished 'copy:source' after 138 ms
[19:37:35] Starting 'inline-resources'...
[19:37:35] Finished 'inline-resources' after 41 ms
[19:37:35] Starting 'ngc'...
[19:37:38] Finished 'ngc' after 2.68 s
[19:37:38] Starting 'rollup:fesm'...
The following options have been renamed — please update your config: sourceMap -> output.sourcemap, format -> output.format
'buffer' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_readable.js, but could not be resolved – treating it as an external dependency
'events' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_readable.js, but could not be resolved – treating it as an external dependency
'util' is imported by node_modules\inherits\inherits.js, but could not be resolved – treating it as an external dependency
'util' is imported by  commonjs-external:util, but could not be resolved – treating it as an external dependency
'util' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_readable.js, but could not be resolved – treating it as an external dependency
'buffer' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_writable.js, but could not be resolved – treating it as an external dependency
'util' is imported by node_modules\util-deprecate\node.js, but could not be resolved – treating it as an external dependency
'events' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_writable.js, but could not be resolved – treating it as an external dependency
'buffer' is imported by  commonjs-external:buffer, but could not be resolved – treating it as an external dependency
'events' is imported by  commonjs-external:events, but could not be resolved – treating it as an external dependency
'buffer' is imported by node_modules\jszip\node_modules\string_decoder\index.js, but could not be resolved – treating it as an external dependency
'LOCALE_ID', 'APP_ID', 'ApplicationInitStatus', 'ApplicationModule', 'ErrorHandler', 'RendererFactory2', 'Sanitizer' and 'Testability' are imported from external module '@angular/core' but never used
'FormGroup' is imported from external module '@angular/forms' but never used
[19:37:46] Finished 'rollup:fesm' after 8.38 s
[19:37:46] Starting 'rollup:umd'...
The following options have been renamed — please update your config: name -> output.name, globals -> output.globals, format -> output.format, exports -> output.exports
'buffer' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_readable.js, but could not be resolved – treating it as an external dependency
'events' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_readable.js, but could not be resolved – treating it as an external dependency
'util' is imported by node_modules\inherits\inherits.js, but could not be resolved – treating it as an external dependency
'util' is imported by  commonjs-external:util, but could not be resolved – treating it as an external dependency
'util' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_readable.js, but could not be resolved – treating it as an external dependency
'buffer' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_writable.js, but could not be resolved – treating it as an external dependency
'util' is imported by node_modules\util-deprecate\node.js, but could not be resolved – treating it as an external dependency
'events' is imported by node_modules\jszip\node_modules\readable-stream\lib\_stream_writable.js, but could not be resolved – treating it as an external dependency
'buffer' is imported by  commonjs-external:buffer, but could not be resolved – treating it as an external dependency
'events' is imported by  commonjs-external:events, but could not be resolved – treating it as an external dependency
'buffer' is imported by node_modules\jszip\node_modules\string_decoder\index.js, but could not be resolved – treating it as an external dependency
'LOCALE_ID', 'APP_ID', 'ApplicationInitStatus', 'ApplicationModule', 'ErrorHandler', 'RendererFactory2', 'Sanitizer' and 'Testability' are imported from external module '@angular/core' but never used
'FormGroup' is imported from external module '@angular/forms' but never used
No name was provided for external module '@angular/core' in options.globals – guessing 'core'
No name was provided for external module '@angular/common' in options.globals – guessing 'common'
No name was provided for external module '@angular/forms' in options.globals – guessing 'forms'
No name was provided for external module 'buffer' in options.globals – guessing 'require$$0'
No name was provided for external module 'events' in options.globals – guessing 'events'
No name was provided for external module 'util' in options.globals – guessing 'debugUtil'
No name was provided for external module '@angular/animations' in options.globals – guessing 'animations'
[19:37:53] Finished 'rollup:umd' after 7.1 s
[19:37:53] Starting 'copy:build'...
[19:37:53] Finished 'copy:build' after 97 ms
[19:37:53] Starting 'copy:manifest'...
[19:37:53] Finished 'copy:manifest' after 4.6 ms
[19:37:53] Starting 'copy:readme'...
[19:37:53] Finished 'copy:readme' after 4.19 ms
[19:37:53] Starting 'clean:build'...
[19:37:53] Finished 'clean:build' after 27 ms
[19:37:53] Starting 'clean:tmp'...
[19:37:53] Finished 'clean:tmp' after 19 ms
Compilation finished succesfully

will test and see if it works.

izifortune commented 6 years ago

Hi @nirving can you please share the source code of events.js?

jvandemo commented 6 years ago

@izifortune — Thank you for your follow-up, much appreciated! 🏆

jwhijazi commented 6 years ago

So what is the final solution for this problem?

gary-holland commented 6 years ago

For those stumbling across this one. After spending way too long on the problem I realised it was an issue with the export. I had:

export * from './directory';

changed it to:

export * from './directory/index';

and the gulp tasks completed.

jvandemo commented 6 years ago

@gary-holland — Thank you for the update, much appreciated!