简体   繁体   English

在 Laravel 应用程序中安装 npm 包

[英]installing npm packages in laravel application

i want to deploy my laravel application now and before doing so i just wanted to know about the npm packages do i install them or keep it like it is ?我想现在和之前部署我的 Laravel 应用程序我只是想知道 npm 包我是安装它们还是保持原样?

the app works more than fine without the need to run npm install.该应用程序运行良好,无需运行 npm install。

the app size is 20000 pages and if i run npm install it'll be 32000.应用程序大小是 20000 页,如果我运行 npm install 它将是 32000。

any help here what to do?有什么帮助吗? and if i install all the packages what's next what should i do?如果我安装了所有软件包,接下来我该怎么办?

    "devDependencies": {
    "axios": "^0.18",
    "bootstrap": "^4.1.0",
    "cross-env": "^5.1",
    "jquery": "^3.2",
    "laravel-mix": "^4.0.7",
    "lodash": "^4.17.5",
    "popper.js": "^1.12",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.15.2",
    "sass-loader": "^7.1.0",
    "vue": "^2.5.17"
}

The packages that you have shown above are all development dependencies so you need those only on your machine in order to perform development.您上面显示的包都是开发依赖项,因此您只需要在您的机器上安装这些包才能执行开发。 When you build it later on using npm run dev or npm run prod , it will get transformed into JS code.当您稍后使用npm run devnpm run prod构建它时,它将被转换为 JS 代码。

So if you say that it the app works on your production server where you want to deploy the app that means that you have the packages that you use globally accessible on the server, or otherwise it will not work 100%.因此,如果您说该应用程序可在您要部署该应用程序的生产服务器上运行,则意味着您拥有可在服务器上全局访问的包,否则它将无法 100% 运行。

So you don't need to run npm install because that will install all the dependencies along with the devDependencies , so you should use npm install --only=prod (or --only=production ) to install only dependencies , and not devDependencies , regardless of the value of the NODE_ENV environment variable.所以你不需要运行npm install因为这将安装所有dependencies以及devDependencies ,所以你应该使用npm install --only=prod (或--only=production )只安装dependencies ,而不是devDependencies ,无论 NODE_ENV 环境变量的值如何。

Note: if you don't have dependencies in your package.json, then there is no need to do this on production server.注意:如果您的 package.json 中没有dependencies ,则无需在生产服务器上执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM