【问题标题】:Laravel docker npm run dev command return errorLaravel docker npm run dev 命令返回错误
【发布时间】:2020-11-25 18:06:22
【问题描述】:

当我运行 docker 命令时:

docker-compose run --rm npm run dev

获取错误消息:

> @ dev /var/www/html
> npm run development


> @ development /var/www/html
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: cross-env: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-08-05T11_52_44_929Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-08-05T11_52_45_060Z-debug.log

docker-compose.yml

version: '3'

services:
  nginx:
    image: nginx:stable-alpine
    container_name: nginx
    ports:
      - "${HOST_PORT}:80"
    volumes:
      - ../:/var/www/html
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php
  php:
    build:
      context: .
      dockerfile: ./Dockerfile
    container_name: php
    volumes:
      - ./php/php.ini:/usr/local/etc/php/conf.d/php.ini
      - ../:/var/www/html
  mongodb:
    image: mongo:latest
    container_name: mongodb
    ports:
      - "${MONGODB_PORT}:27017"
  redis:
    image: redis:latest
    container_name: redis
    restart: always
    ports:
      - "${REDIS_PORT}:6379"
  artisan:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: artisan
    volumes:
      - ../:/var/www/html
    working_dir: /var/www/html
    entrypoint: ['/var/www/html/artisan']
  npm:
    image: node:14-alpine
    container_name: npm
    volumes:
      - ../:/var/www/html
    working_dir: /var/www/html
    entrypoint: ['npm']

【问题讨论】:

    标签: node.js laravel docker npm


    【解决方案1】:

    我认为问题在于,未找到或丢失 npm cross-env 包。

    https://www.npmjs.com/package/cross-env

    您可以通过调用来安装它: npm i cross-env

    【讨论】:

      猜你喜欢
      • 2018-03-25
      • 2017-08-20
      • 2022-10-04
      • 2022-08-07
      • 2021-04-11
      • 1970-01-01
      • 2019-01-09
      • 2017-12-28
      • 2021-11-25
      相关资源
      最近更新 更多