【问题标题】:Angular ag-grid projects works locally but not on server: compiling errorsAngular ag-grid 项目在本地工作但不在服务器上工作:编译错误
【发布时间】:2019-08-08 22:55:46
【问题描述】:

我在我的项目中使用 ag-grid,使用 ng serve 在本地运行它可以正常工作并且符合预期。但是当上传到服务器时,编译总是失败,基本上是以下错误:

ERROR in src\app\app.module.ts(87,5): Error during template compile of 'AppModule'

  Could not resolve ag-grid-angular relative to c:/workspace/.../Angular/src/app/app.module.ts..

src/app.../status-cellrenderer.component.ts(2,37): error TS2307: Cannot find module 'ag-grid-angular'.

src/app/app.module.ts(36,30): error TS2307: Cannot find module 'ag-grid-angular'.

我使用 ag-grid 版本 20.0.0 并使用本教程:https://medium.com/ag-grid/get-started-with-angular-grid-in-5-minutes-83bbb14fac93

编辑: 这是服务器上的配置:

cd Angular
cmd /c call npm install 
@ECHO ############ Node.js Packages installed  ###################
REM cmd /c call node_modules/.bin/ng --version
@ECHO ############ Build Angular-Site  ##################
cmd /c call node_modules/.bin/ng build --prod --output-path=..\PublishOutput

nodes_modules目录不是我自己上传的..

【问题讨论】:

  • 您是否设置了构建服务器来检索丢失的 npm-packages (npm install)?通常 node_modules 文件夹是并且不应与您的源代码一起提交。
  • 我已经编辑了第一篇文章

标签: angular ag-grid ag-grid-angular


【解决方案1】:

删除 node_modules 目录解决了问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-01
    • 2020-01-25
    • 2023-01-02
    • 2017-02-22
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    相关资源
    最近更新 更多