【问题标题】:npm install not working in laravel 5.6npm install 在 laravel 5.6 中不起作用
【发布时间】:2018-07-30 07:22:08
【问题描述】:

通过 composer 全新安装 laravel 5.6

我是如何安装的:

composer create-project laravel/laravel

安装后我跑了:

npm install

我回来了:

npm notice created a lockfile as package-lock.json. You should commit this file. Up to date in 0.163s.

它不会创建 node_modules 文件夹。

如果我尝试使用yarn 安装依赖项:

yarn install

我回来了:

yarn install v1.3.2 info No lockfile found. Resolving packages... warning laravel-mix > img-loader > imagemin-mozjpeg > mozjpeg > bin-wrapper > download > gulp-decompress > gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidlines at https://medium.com/gulpjs/gulp-util-ca3b1f9fac5 | Fetching packages... info fsevents@1.1.3: The platform 'win32' is incompatible with this module. info "fsevents@1.1.3" is an optional dependency and failed compatability check. Excluding it from installation. Linking dependencies.... Building fresh packages... success Saved lockfile. Done in 35.38s

这会创建一个 node_modules 文件夹,其中只有“.yarn-integrity”没有模块。

到中页的链接失效,收到 404 所以没有运气。

我的节点版本是:“v8.9.4”,我的纱线版本是:'v1.3.2'

  • 编辑:这不是 git 问题。我没有使用 git

【问题讨论】:

  • 在你创建项目之后运行npm install之前,你有没有cd进入项目目录?
  • 是的,我做到了。我目前在项目目录中。

标签: node.js laravel laravel-5 npm


【解决方案1】:

package-lock.json 会自动为 npm 修改 node_modules 树或 package.json 的任何操作生成。它描述了生成的确切树,以便后续安装能够生成相同的树,而不管中间依赖项更新如何。

运行以下命令

  1. git add -A
  2. git commit -m "Commit package-lock.json"
  3. git push -u origin master

现在重新运行npm install

【讨论】:

    【解决方案2】:

    运行:

    npm install --dev or npm install --only=dev
    

    这安装了我需要的依赖项。无论出于何种原因,在 laravel 5.6 中,所有依赖项都被视为 package.json 文件中的 devDependencies。

    【讨论】:

    • npm install --only=dev,第一个现已弃用。
    【解决方案3】:

    只要确保你在你的项目目录中,例如

    1) cd 路径/to/my_laravel_project
    2) npm 安装

    【讨论】:

      【解决方案4】:

      这是因为你不在 laravel 根目录下,所以当你创建一个项目时,一开始你不在这个目录下,你需要打开你的项目文件夹并使用

      npm i
      

      【讨论】:

        猜你喜欢
        • 2021-07-18
        • 1970-01-01
        • 2018-04-17
        • 2022-01-15
        • 1970-01-01
        • 2018-09-28
        • 2016-05-03
        • 2017-11-12
        • 2013-11-03
        相关资源
        最近更新 更多