jelbourn / material2-app

Simple app that consumes Angular Material 2 components
650 stars 278 forks source link

assets folder doesn't exist #24

Open invegat opened 7 years ago

invegat commented 7 years ago

ng server made this error "ENOENT: no such file or directory, stat 'C:\Angular2\material2-app\src\assets'" my actions: git clone -b master --single-branch https://github.com/jelbourn/material2-app.git cd material2-app npm install npm start


The directory 'C:\Angular2\material2-app\src\assets'" doesn't exist.

realtebo commented 7 years ago

I'm using latest node LTS (6.9.1) and npm is at v3.10.9 on Windows 7 Pro 64 bit. Same problem.

Error: ENOENT: no such file or directory, stat 'C:\Users\realtebo\Downloads\material2-app\src\assets'
    at Error (native)
    at Object.fs.statSync (fs.js:987:18)
    at C:\Users\realtebo\Downloads\material2-app\node_modules\angular-cli\plugins\glob-copy-webpack-plugin.js:16:64
    at Array.map (native)
    at GlobCopyWebpackPlugin.apply (C:\Users\realtebo\Downloads\material2-app\node_modules\angular-cli\plugins\glob-copy-webpack-plugin.js:16:29)
    at Compiler.apply (C:\Users\realtebo\Downloads\material2-app\node_modules\tapable\lib\Tapable.js:233:16)
    at WebpackOptionsApply.process (C:\Users\realtebo\Downloads\material2-app\node_modules\webpack\lib\WebpackOptionsApply.js:59:18)
    at webpack (C:\Users\realtebo\Downloads\material2-app\node_modules\webpack\lib\webpack.js:28:48)
    at Class.run (C:\Users\realtebo\Downloads\material2-app\node_modules\angular-cli\tasks\serve-webpack.js:25:27)
    at C:\Users\realtebo\Downloads\material2-app\node_modules\angular-cli\commands\serve.js:93:26
    at process._tickCallback (internal/process/next_tick.js:103:7)

I noticed these warn at the end of build process:

npm WARN @ngtools/webpack@1.1.6 requires a peer of @angular/compiler-cli@2.2.1 but none was installed.
npm WARN @ngtools/webpack@1.1.6 requires a peer of @angular/core@2.2.1 but none was installed.
realtebo commented 7 years ago
cd src
mkdir assets
cd ..
ng server

But it's still NOT working

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './aot/app/app.module.ngfactory' in 'C:\Users\realtebo\Downloads\material2-app\src'
 @ ./src/main.ts 8:0-76
 @ multi main
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks       Chunk Names
    index.html  3.4 kB       0
webpack: bundle is now VALID.
[default] Checking started in a separate process...
[default] C:\Users\realtebo\Downloads\material2-app\src\main.ts:25:42
    Cannot find module './aot/app/app.module.ngfactory'.
[default] Checking finished with 1 errors
barakakoun commented 7 years ago

Try this:

  1. Make the 'assets' folder manually
  2. Run ./node_modules/.bin/ngc -p ./src/ (as written in the main.ts file) Then run again. Worked for me :)
realtebo commented 7 years ago

I restart from scratch. Note that I'm workingw with node 6.9.1,npm, 3.10.9, Windows 7 Pro 64bit, on a subdir of folder, so I surely have read/write permissions. Also, each of following commands is executed from a command prompt without admin rights.

Completely clear npm cache

rmdir <my_user>\AppData\Roaming\npm-cache /Q /S

Remove entire folder project

rmdir <my_user>\material2-app /Q /S

Re-cloned and re-installed npm modules

cd <my_user>\Downloads
git clone https://github.com/jelbourn/material2-app.git
cd material2-app
npm install

Trying @barakakoun 's method

cd src
mkdir assets
cd ..
.\node_modules\.bin\ngc -p .\src\
ng server

Esit

App working

Question 1: why is it needed AoT compiling? Question 2: what does ngc -p do ?

Suggestion: please add to main read.me a short paragraph about the need of Aot compiling. I think other newbies, like me, never will open the main.ts before try to run it.

hswolf commented 7 years ago

Hi @realtebo, For your questions:

  1. It is related to performance, you can find more here https://angular.io/docs/ts/latest/cookbook/aot-compiler.html
  2. I have no idea :), but if you take a look at src/main.ts there is a comment say that you need to run that comment before boostraping the app.