timonweb / django-tailwind

Django + Tailwind CSS = 💚
https://django-tailwind.readthedocs.io
MIT License
1.46k stars 92 forks source link

npm is not installed error #1

Closed liinapytt closed 5 years ago

liinapytt commented 5 years ago

Everything works fine until the: python manage.py tailwind install

Then it throws an error: CommandError: npm is not installed or cannot be found at path "None"

Any ideas? Thanks in advance

timonweb commented 5 years ago

This means you don't have node.js installed on your machine. Please check here: https://nodejs.org/en/. I'll improve the error message in the future, you were too fast to find this package :)

liinapytt commented 5 years ago

Actually I do have it installed (v8.12.0), that's why the error is weird.

timonweb commented 5 years ago

aha, then probably it's not in the path that your Python env can see. I'm planning to add "NODE_BIN_PATH" variable so that users could specify node path explicitly if needed.

As a backup plan, you can directly invoke node commands instead of using manage.py tailwind. Go to your tailwind's app static_src folder and type: npm install and see if it works.

If yes, than you can use npm start for dev mode and npm run build for production mode.

liinapytt commented 5 years ago

npm install in static_src folder worked, it loaded the necessary node_modules. However the npm start gave errors again:

Error: ENOENT: no such file or directory, stat 'C:\Users\User\PycharmProjects\projectname\theme\static_src\run' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! django_tailwind@1.0.0 start: watch 'npm run build-postcss' ./src npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the django_tailwind@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Should there be a run directory? Or should I modify the script in package.json somehow?

timonweb commented 5 years ago

@liinapytt are you trying to run this on Windows maybe?

liinapytt commented 5 years ago

yep, I should probably set NODE_ENV and NODE_PATH in windows environment? As google tells me :) Or is there something more?

timonweb commented 5 years ago

@liinapytt try this, also try to fiddle with this command watch 'npm run build-postcss' ./src. Try to type it in manually, also try to replace single quotes with double quotes and let me know if this worked.

timonweb commented 5 years ago

@liinapytt I've just updated django-tailwind to v0.1.0, try to set NPM_BIN_PATH as described here: https://github.com/timonweb/django-tailwind#npm-executable-path-configuration

yukk670 commented 5 years ago

python manage.py tailwind install

then(I just hava python3.6):

gyp verb check python checking for Python executable "python2" in the PATH gyp verb which failed Error: not found: python2 gyp verb which failed at getNotFoundError (D:\untitled1\theme\static_src\node_modules\which\which.js:13:12) gyp verb which failed at F (D:\untitled1\theme\static_src\node_modules\which\which.js:68:19) gyp verb which failed at E (D:\untitled1\theme\static_src\node_modules\which\which.js:80:29) gyp verb which failed at D:\untitled1\theme\static_src\node_modules\which\which.js:89:16 gyp verb which failed at D:\untitled1\theme\static_src\node_modules\isexe\index.js:42:5 gyp verb which failed at D:\untitled1\theme\static_src\node_modules\isexe\windows.js:36:5 gyp verb which failed at FSReqWrap.oncomplete (fs.js:153:21)