【问题标题】:Angular 6: getting error with starting my app with npm startAngular 6:使用 npm start 启动我的应用程序时出错
【发布时间】:2019-04-18 11:03:32
【问题描述】:

我从事 Angular 6 项目已经有很长时间了,当我的项目文件夹中有 node_modules 文件夹时,它工作得很好。 我希望能够在我的项目中没有node_modules 的情况下运行我的项目,因此我将node_modules 文件夹移动到父文件夹并在angular.json 中更改了以../node_modules 开头的路径。 我认为它会起作用,但是在我写 npm start 之后我得到了这个错误:

pm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! lg-academy@0.0.0 start: `ng serve --configuration=production --host 0.0.0.0 --port 4200 --verbose --disable-host-check`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the lg-academy@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ofir/.npm/_logs/2018-11-15T1

提前感谢所有帮助者

【问题讨论】:

  • 你之前跑过npm i吗?
  • 你不能简单地移动node_modules,它必须在package.json 所在的位置——你为什么觉得有必要移动它?
  • 通常您不会重新定位 node_modules 文件夹。它很重,是的,但是如果您想将项目部署到生产服务器,您只需不上传 node_modules 文件夹即可。您只需要那里的 package.json 文件并在生产服务器上执行“npm install”即可。
  • 我不敢这么说,但它应该是那样的。带有 package.json 的项目必须依赖 node_modules 文件夹,该文件夹存储所有项目依赖项。你应该考虑在部署时运行一些脚本来自动npm install
  • Angular 应用的生产模式一般是由 build 命令创建的静态文件,所以你在生产中不需要任何这些。

标签: angular npm dependencies node-modules package.json


【解决方案1】:

在我在这里和谷歌上得到答案并询问了我的一些朋友之后,我刚刚部署了所有内容并将 node_modules 返回到我的项目文件夹。部署它需要很多时间,但没有其他方法。

感谢您的 cmets 和帮助!

【讨论】:

    猜你喜欢
    • 2019-09-29
    • 2023-01-13
    • 2019-12-26
    • 2015-08-19
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    相关资源
    最近更新 更多