Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in ng serve "Could not resolve module"

I create a new angular project by angular cli using this command:

$ ng new ng5-app

I wait until all the file created and all the dependencies installed, and after all of those tasks, when I try to run the app using:

$ ng serve

this errors shows up:

            ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ ** Date: 2018-01-26T14:12:03.297Z
            Hash: 2238da56910f9b52c46b
            Time: 2158ms
            chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
            chunk {main} main.bundle.js (main) 2.93 kB [initial] [rendered]
            chunk {polyfills} polyfills.bundle.js (polyfills) 636 bytes [initial] [rendered]
            chunk {styles} styles.bundle.js (styles) 33.6 kB [initial] [rendered]
            chunk {vendor} vendor.bundle.js (vendor) 852 kB [initial] [rendered]

            ERROR in Error: Could not resolve module H:/
                at StaticSymbolResolver.getSymbolByModule (H:\#htdocs\ng5-app\node_modules\@angular\compiler\bundles\compiler.umd.js:29765:30)
                at StaticReflector.resolveExternalReference (H:\#htdocs\ng5-app\node_modules\@angular\compiler\bundles\compiler.umd.js:31610:62)
                at parseLazyRoute (H:\#htdocs\ng5-app\node_modules\@angular\compiler\bundles\compiler.umd.js:29049:55)
                at AotCompiler.listLazyRoutes (H:\#htdocs\ng5-app\node_modules\@angular\compiler\bundles\compiler.umd.js:31142:43)
                at AngularCompilerProgram.listLazyRoutes (H:\#htdocs\ng5-app\node_modules\@angular\compiler-cli\src\transformers\program.js:156:30)
                at Function.NgTools_InternalApi_NG_2.listLazyRoutes (H:\#htdocs\ng5-app\node_modules\@angular\compiler-cli\src\ngtools_api.js:44:36)
                at AngularCompilerPlugin._getLazyRoutesFromNgtools (H:\#htdocs\ng5-app\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:248:66)
                at Promise.resolve.then.then (H:\#htdocs\ng5-app\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:565:50)
                at process._tickCallback (internal/process/next_tick.js:103:7)

            webpack: Failed to compile.

What is the problem of this error?

like image 679
Hamid Yaftian Avatar asked Jan 26 '18 14:01

Hamid Yaftian


2 Answers

I found the solution. I was creating the app folder in #htdocs folder. I moved it outside it and everything works fine. That's so Weird!!!

like image 118
Hamid Yaftian Avatar answered Nov 18 '22 14:11

Hamid Yaftian


The problem here is the #. Remove it and everything will work fine.

like image 25
Lomanto Avatar answered Nov 18 '22 12:11

Lomanto