我在尝试构建我的角度2项目时遇到了问题。当我调用ng build
时,构建器将路由路径验证为模块,并说它不存在:
ERROR in无法解析" app / membros / membro.module"来自" C:/Users/bruno.martins/git/disciples-ui/src/app/app.module.ts"。
C:\Users\bruno.martins\git\disciples-ui>npm install
> disciples-ui@0.0.0 postinstall C:\Users\bruno.martins\git\disciples-ui
> ng build --prod
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.
To disable this warning use "ng set --global warnings.packageDeprecation=false".
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
Hash: d8f6b3f0c56af167dadf
Time: 16957ms
chunk {0} polyfills.97e9eeda4d76d39a40b8.bundle.js (polyfills) 239 kB {4} [initial] [rendered]
chunk {1} main.c2b4bf4bdc30f5037cb6.bundle.js (main) 13.6 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.45864682c5b5d47e6aa5.bundle.js (vendor) 2.35 MB [initial] [rendered]
chunk {4} inline.30690479fd56d04d5cd5.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in Could not resolve "app/membros/membro.module" from "C:/Users/bruno.martins/git/disciples-ui/src/app/app.module.ts".
问题在于:
RouterModule.forRoot([
{
path: 'membro',
loadChildren: 'app/membros/membro.module#MembroModule'
},
{
path : 'testador',
loadChildren: 'app/testador/testador.module#TestadorModule'
}
])
如果我删除了这个' loadChildren',那么构建运行正常!实际上,这是正确的,因为应用程序开始没有问题并且有效。我正在heroku部署这个应用程序,所以我必须在Heroku使用ng build
(这个命令也在本地提供错误);在本地,我只使用npm start
(使用此应用程序正常运行)。
这也是我的package.json:
{
"name": "disciples-ui",
"version": "0.0.0",
"license": "",
"angular-cli": {},
"scripts": {
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./src/**/*.ts -t verbose",
"ng": "ng",
"postinstall": "ng build --prod",
"start-heroku": "node server.js"
},
"private": true,
"dependencies": {
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/core": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/platform-browser-dynamic": "~4.0.0",
"@angular/router": "~4.0.0",
"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.8.4",
"ng": "0.0.0-rc6",
"angular-cli": "1.0.0-beta.28.3",
"@angular/compiler-cli": "~4.0.0"
},
"devDependencies": {
"@types/jasmine": "2.5.36",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.2.0",
"core-js": "^2.4.1",
"express": "^4.15.2",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"ts-helpers": "^1.1.1",
"tslint": "^3.15.1",
"typescript": "~2.2.1"
}
}
你能帮帮我们吗?
答案 0 :(得分:9)
您的问题有两种可能的解决方案:
这里描述:https://stackoverflow.com/a/48028980/5816097
使用GROUP BY table1.key;
代替./membros/membro.module#MembroModule
。
app/membros/membro.module#MembroModule
baseUrl
在compilerOptions
下src/tsconfig.app.json
添加baseUrl: "./"
:
compilerOptions