npm 安装在 Laravel 5.6 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48876651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install not working in laravel 5.6
提问by blaze-rowland
On a fresh install of laravel 5.6 via composer
通过 composer 全新安装 laravel 5.6
How I installed it:
我是如何安装它的:
composer create-project laravel/laravel
After installing I ran:
安装后我跑了:
npm install
I get back:
我回来了:
npm notice created a lockfile as package-lock.json. You should commit this file. Up to date in 0.163s.
It does not create a node_modules folder.
它不会创建 node_modules 文件夹。
If I try using yarn
to install the dependencies using:
如果我尝试使用以下yarn
方法安装依赖项:
yarn install
I get back:
我回来了:
yarn install v1.3.2 info No lockfile found. Resolving packages... warning laravel-mix > img-loader > imagemin-mozjpeg > mozjpeg > bin-wrapper > download > gulp-decompress > [email protected]: gulp-util is deprecated - replace it, following the guidlines at https://medium.com/gulpjs/gulp-util-ca3b1f9fac5 | Fetching packages... info [email protected]: The platform 'win32' is incompatible with this module. info "[email protected]" is an optional dependency and failed compatability check. Excluding it from installation. Linking dependencies.... Building fresh packages... success Saved lockfile. Done in 35.38s
This creates a node_modules
folder with only ".yarn-integrity' no modules.
这将创建一个node_modules
只有“.yarn-integrity”没有模块的文件夹。
The link to the medium page doesn't work, receive 404 so no luck there.
指向中等页面的链接不起作用,收到 404,所以没有运气。
My node version is: "v8.9.4" and my yarn version is: 'v1.3.2'
我的节点版本是:“v8.9.4”,我的纱线版本是:“v1.3.2”
- Edit: This isn't a git issue. I'm not using git
- 编辑:这不是 git 问题。我没有使用 git
回答by blaze-rowland
running:
跑步:
npm install --dev or npm install --only=dev
This installed the dependencies I needed. For whatever reason in laravel 5.6 all the dependencies are considered devDependencies in the package.json file.
这安装了我需要的依赖项。无论出于何种原因,在 laravel 5.6 中,所有依赖项都被视为 package.json 文件中的 devDependencies。
回答by Hassan Krayem
Just make sure you are in your project directory e.g
只要确保你在你的项目目录中,例如
1) cd path/to/my_laravel_project
2) npm install
1) cd path/to/my_laravel_project
2) npm 安装
回答by Abdi
this because you are not in laravel root folder, when you create a project, at first you are not in folder you need to open your project folder and use
这是因为您不在 laravel 根文件夹中,当您创建项目时,起初您不在文件夹中,您需要打开项目文件夹并使用
npm i
回答by Prince Lionel N'zi
package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
对于 npm 修改 node_modules 树或 package.json 的任何操作,都会自动生成 package-lock.json。它描述了生成的确切树,以便后续安装能够生成相同的树,而不管中间依赖项更新如何。
Run the following command
运行以下命令
git add -A
git commit -m "Commit package-lock.json"
git push -u origin master
git add -A
git commit -m "Commit package-lock.json"
git push -u origin master
Now re-run npm install
现在重新运行 npm install