无法在开发模式下启动 Django-Tailwind
Posted
技术标签:
【中文标题】无法在开发模式下启动 Django-Tailwind【英文标题】:Can't Start Django-Tailwind in Dev Mode 【发布时间】:2020-03-06 03:33:58 【问题描述】:我正在 Windows 上使用 django-tailwind,并按照步骤进行安装。当前步骤是使用python manage.py tailwind start
“在开发模式下启动顺风”。这总是失败,以下文本块是生成的日志文件:
...
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle django_tailwind@~prestart: django_tailwind@
6 info lifecycle django_tailwind@~start: django_tailwind@
7 verbose lifecycle django_tailwind@~start: unsafe-perm in lifecycle true
8 verbose lifecycle django_tailwind@~start: PATH: C:\Users\jpyth\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;c:\Users\jpyth\Django\hhs-robotics-website\theme\static_src\node_modules\.bin;C:\Users\jpyth\Django\hhs-robotics-website\venv\Scripts;C:\ActiveTcl\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\jpyth\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\jpyth\AppData\Local\Programs\Python\Python37\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Gpg4win\..\GnuPG\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\GCL-2.6.1\bin\;C:\ccl\launcher;C:\Program Files (x86)\ffmpeg\bin;C:\opencv\sources\3rdparty\ffmpeg\;C:\Users\jpyth\AppData\Local\Programs\Python\Python37\Scripts\;C:\ActiveTcl\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\jpyth\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\jpyth\AppData\Local\Programs\Python\Python37\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Gpg4win\..\GnuPG\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\GCL-2.6.1\bin\;C:\ccl\launcher;C:;C:\Users\jpyth\AppData\Local\Programs\Microsoft VS Code\bin
9 verbose lifecycle django_tailwind@~start: CWD: c:\Users\jpyth\Django\hhs-robotics-website\theme\static_src
10 silly lifecycle django_tailwind@~start: Args: [ '/d /s /c', "watch 'npm run build-postcss' ./src" ]
11 silly lifecycle django_tailwind@~start: Returned: code: 1 signal: null
12 info lifecycle django_tailwind@~start: Failed to exec start script
13 verbose stack Error: django_tailwind@ start: `watch 'npm run build-postcss' ./src`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\jpyth\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\jpyth\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid django_tailwind@
15 verbose cwd c:\Users\jpyth\Django\hhs-robotics-website\theme\static_src
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jpyth\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
18 verbose node v12.13.0
19 verbose npm v6.7.0
20 error code ELIFECYCLE
21 error errno 1
22 error django_tailwind@ start: `watch 'npm run build-postcss' ./src`
22 error Exit status 1
23 error Failed at the django_tailwind@ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我注意到的一件事是它失败的命令使用watch
,这不是 Windows 命令。但是,我确实尝试将输入运行到 watch
(npm run build-postcss
) 但无济于事。我什至创建了一个自定义的 watch.bat
脚本,将其添加到 PATH 中,但它仍然失败。我不知道从这里去哪里。如何让 tailwind css 在我的 Django 应用程序中工作?
【问题讨论】:
杰西你有解决方案吗,如果有的话,介意分享一下,我遇到了同样的问题 【参考方案1】:抱歉,昨天来晚了,遇到了同样的事情,遇到了你的问题,但这是修复,因为我们使用的是 Windows,所以我们必须更改
我们使用的 qoutes
在 ./theme/static_src/package.json 更改
"start": "watch 'npm run build-postcss' ./src"
到
"start": "watch \"npm run build-postcss\" ./src"
【讨论】:
这就是解决方案。谢谢你,乔丹。【参考方案2】:由于 2020 年 5 月 14 日 中的 package.json 发生了更改启动命令,因此上述答案不再有效。 (see the change here) 正因为如此,另一个问题出现了。要解决这个问题,您必须在 theme/static_src/package.json 中更改以下内容:
"dev": "watch 'npm run dev:sass && npm run dev:postcss' ./src",
到
"dev": "watch \"npm run dev:sass && npm run dev:postcss\" ./src",
希望这会有所帮助!
【讨论】:
以上是关于无法在开发模式下启动 Django-Tailwind的主要内容,如果未能解决你的问题,请参考以下文章
如何在调试模式下启动本机应用程序而不在开发人员菜单中远程选择调试 js