NG构建--prod扔errr
问题描述:
我使用ng build --prod
命令却是露出像NG构建--prod扔errr
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in 'C:\Users\allud\MyCafe\src'
resolve './app/app.module.ngfactory' in 'C:\Users\allud\MyCafe\src'
using description file: C:\Users\allud\MyCafe\package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Users\allud\MyCafe\package.json (relative path: ./src)
using description file: C:\Users\allud\MyCafe\package.json (relative path: ./src/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\allud\MyCafe\src\app\app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\allud\MyCafe\src\app\app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\allud\MyCafe\src\app\app.module.ngfactory.js doesn't exist
as directory
C:\Users\allud\MyCafe\src\app\app.module.ngfactory doesn't exist
[C:\Users\allud\MyCafe\src\app\app.module.ngfactory]
[C:\Users\allud\MyCafe\src\app\app.module.ngfactory.ts]
[C:\Users\allud\MyCafe\src\app\app.module.ngfactory.js]
[C:\Users\allud\MyCafe\src\app\app.module.ngfactory]
@ ./src/main.ts 3:0-66
@ multi ./src/main.ts
答
错误似乎线路节点缓存模块的问题。 请尝试以下给出命令:
cd {your-project}
npm -f cache clean
rm -f package-lock.json
rm -rf node_modules
npm install
如果它不工作,你的清洁和.npm主目录中的.node-GYP。
答
有几件事情,你可以验证,
-
确定你是否在正确的目录加载组件,我指的是组件的
Import
声明import PackageName from './FromFolder';
删除路径node_modules并重新安装所有软件包
- 用更新的软件包更新您的Angular CLI版本
现在尝试ng build --prod
你可以发布您的代码,以及? –
我还没有编码任何东西。我刚开始使用新的myCafe,cd myCafe,然后是ng build --prod。这是抛出错误。 ng可以正常工作,因此代码还没有问题。 –
哪个版本的'anglular'和'CLI'? – Aravind