Django + tailwind : tailwind не работает в среде развертывания на сервере ubuntu

Я создал сайт в среде разработки, используя django и tailwind. Я разместил проект на github, а затем клонировал его внутри экземпляра ec2. Развертывание прошло нормально (сайт работает), за исключением того факта, что tailwind не работает. Пожалуйста, простите меня, если мой вопрос глупый, это мой первый проект с использованием tailwind.

Я убедился, что версия node.js и версия npm одинаковы в моей локальной среде и на моем сервере ubuntu, но я все еще получаю проблему.

Из документации по django-tailwind https://django-tailwind.readthedocs.io/en/latest/usage.html , получение tailwind для развертывания было следующей командой.

python manage.py tailwind build

выполнение этого действия на моем рабочем сервере приводит к следующей ошибке:

node:internal/modules/cjs/loader:939
  const err = new Error(message);
              ^

Error: Cannot find module 'semver'
Require stack:
- /usr/share/nodejs/npm/lib/utils/unsupported.js
- /usr/share/nodejs/npm/lib/cli.js
- /usr/share/nodejs/npm/bin/npm-cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Module._load (node:internal/modules/cjs/loader:780:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/share/nodejs/npm/lib/utils/unsupported.js:2:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/nodejs/npm/lib/utils/unsupported.js',
    '/usr/share/nodejs/npm/lib/cli.js',
    '/usr/share/nodejs/npm/bin/npm-cli.js'
  ]
}

Node.js v18.2.0

это странно, потому что

  1. Я установил его и все равно не нахожу:
which semver
/usr/local/bin/semver

и 2. Он был необходим, но его даже не было в среде разработки.

вот как выглядит tailwind.config.js:

module.exports = {
    content: [
        /**
         * HTML. Paths to Django template files that will contain Tailwind CS>
         */

        /*  Templates within theme app (<tailwind_app_name>/templates), e.g. >
        '../templates/**/*.html',

        /* 
         * Main templates directory of the project (BASE_DIR/templates).
         * Adjust the following line to match your project structure.
         */
        '../../templates/**/*.html',
        
        /* 
         * Templates in other django apps (BASE_DIR/<any_app_name>/templates).
         * Adjust the following line to match your project structure.
         */
        '../../**/templates/**/*.html',

        /**
         * JS: If you use Tailwind CSS in JavaScript, uncomment the following>
         * patterns match your project structure.
         */
        /* JS 1: Ignore any JavaScript in node_modules folder. */
        // '!../../**/node_modules',
        /* JS 2: Process all JavaScript files in the project. */
        // '../../**/*.js',

        /**
         * Python: If you use Tailwind CSS classes in Python, uncomment the f>
         * and make sure the pattern below matches your project structure.
         */
        // '../../**/*.py'
    ],
    theme: {
        extend: {},
    },
    plugins: [
        /**
         * '@tailwindcss/forms' is the forms plugin that provides a minimal s>
         * for forms. If you don't like it or have own styling for forms,
         * comment the line below to disable '@tailwindcss/forms'.
         */
        require('@tailwindcss/forms'),
        require('@tailwindcss/typography'),
        require('@tailwindcss/line-clamp'),
        require('@tailwindcss/aspect-ratio'),
    ],

        
}

и вот мой файл package.json:

{
  "name": "theme2",
  "version": "3.1.1",
  "description": "",
  "scripts": {
    "start": "npm run dev",
    "build": "npm run build:clean && npm run build:tailwind",
    "build:clean": "rimraf ../static/css/dist",
    "build:tailwind": "cross-env NODE_ENV=production tailwindcss --postcss -i>
    "dev": "cross-env NODE_ENV=development tailwindcss --postcss -i ./src/sty>
    "tailwindcss": "node ./node_modules/tailwindcss/lib/cli.js"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@tailwindcss/aspect-ratio": "^0.4.0",
    "@tailwindcss/forms": "^0.4.0",
    "@tailwindcss/line-clamp": "^0.3.1",
    "@tailwindcss/typography": "^0.5.0",
    "cross-env": "^7.0.3",
    "postcss": "^8.4.5",
    "postcss-import": "^14.0.2",
    "postcss-nested": "^5.0.6",
    "postcss-simple-vars": "^6.0.3",
    "rimraf": "^3.0.2",
    "tailwindcss": "^3.1.6"
  }
}

Я в замешательстве, что делать с этой ошибкой или что делать, чтобы все заработало, мало что можно найти в интернете, так что любой совет будет приветствоваться!!!

Вернуться на верх