ng服务错误"无法解析模块"

时间:2018-01-26 14:02:41

标签: angular angular-cli

我使用此命令通过angular cli创建一个新的角度项目:

$ ng new ng5-app

我等到创建了所有文件并安装了所有依赖项,并且在所有这些任务之后,当我尝试使用以下命令运行应用程序时:

$ ng serve

出现这个错误:

            ** 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.

这个错误有什么问题?

2 个答案:

答案 0 :(得分:4)

我找到了解决方案。 我在#htdocs文件夹中创建了app文件夹。我把它移到了外面,一切正常。那太奇怪了!!!

答案 1 :(得分:1)

这里的问题是#。删除它,一切都会正常工作。