Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for using Crafty as a module #1197

Open
ExperiBass opened this issue Dec 2, 2018 · 10 comments
Open

Update documentation for using Crafty as a module #1197

ExperiBass opened this issue Dec 2, 2018 · 10 comments

Comments

@ExperiBass
Copy link

I'm helping develop a top-down game for desktop, so I need to use crafty as a module in VSCode. How can I do that? I don't see anything in the docs about this.

@starwed
Copy link
Member

starwed commented Dec 2, 2018

Have you tried using it via the npm module?

There's an example app you can look at here, though it's from a few versions ago.

@ExperiBass
Copy link
Author

ExperiBass commented Dec 2, 2018

Theres not much info in the README, do I have to cd into the crafty-develop folder?
EDIT: im dumb lol, I didn't realize there was a npm module. thanks! Another question: can Crafty be used outside a html file? I was reading the docs, and it seems you need a html page to use Crafty.

@ExperiBass
Copy link
Author

Also, installing craftyjs outputs a bunch of errors.

$ npm i craftyjs

> craftyjs@0.9.0 postinstall /Users/gingkathfox/node_modules/craftyjs
> (node -e "process.env.NODE_ENV !== 'production' && process.exit()" && grunt copy:lib) || node -v

A valid Gruntfile could not be found. Please see the getting started guide for
more information on how to configure grunt: http://gruntjs.com/getting-started
Fatal error: Unable to find Gruntfile.
v8.9.4
npm WARN saveError ENOENT: no such file or directory, open '/Users/gingkathfox/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/gingkathfox/package.json'
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of libsodium-wrappers@^0.5.4 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.0 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
npm WARN gingkathfox No description
npm WARN gingkathfox No repository field.
npm WARN gingkathfox No README data
npm WARN gingkathfox No license field.

+ craftyjs@0.9.0
added 40 packages from 139 contributors and audited 11369 packages in 12.809s
found 177 vulnerabilities (77 low, 42 moderate, 54 high, 4 critical)
  run `npm audit fix` to fix them, or `npm audit` for details

@ExperiBass
Copy link
Author

$ npm audit
npm ERR! code EAUDITNOPJSON
npm ERR! audit No package.json found: Cannot audit a project without a package.json

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gingkathfox/.npm/_logs/2018-12-02T16_21_49_339Z-debug.log

log:

@starwed
Copy link
Member

starwed commented Dec 2, 2018

A valid Gruntfile could not be found. Please see the getting started guide for
more information on how to configure grunt: http://gruntjs.com/getting-started
Fatal error: Unable to find Gruntfile.

This one looks like an issue with the package.config -- it's a step that's necessary when developing with crafty, but not when installing it as a module. It's getting run as a postinstall script, so even with the error it would normally mean that crafty had installed ok. However:

v8.9.4
npm WARN saveError ENOENT: no such file or directory, open '/Users/gingkathfox/package.json'

and

No package.json found: Cannot audit a project without a package.json

These errors look like you're trying to install crafty into a place that isn't set up as a node project. If you're in the folder for your project, you'll want to start by either creating a package.json file, or running npm init to create one automatically.

Another question: can Crafty be used outside a html file?

All of the rendering methods assume assume some sort of DOM/html context. It's possible to build a headless version of crafty that could run in the context of a node server, but that doesn't sound like what you're going for.

@starwed
Copy link
Member

starwed commented Dec 2, 2018

I think PR #1199 will fix the errors when you don't have grunt installed in the future. (But not until we release a new version on npm.)

@ExperiBass
Copy link
Author

ok!

@starwed starwed changed the title Using crafty with require() Update documentation for using Crafty as a module Dec 8, 2018
@starwed
Copy link
Member

starwed commented Dec 8, 2018

I think the main issue here is that we need better docs on using Craft as a module, so updating the title to that.

@ExperiBass
Copy link
Author

Hmmm, yeah, that's a better title XD

@starwed starwed added the docs label Dec 9, 2018
@ExperiBass
Copy link
Author

@starwed the example app helped, thanks! i have another, completely different question though. Do you have a discord so we can chat?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants