I am trying to install graphcool in a node.js project on my local machine. (I'm a newbie so I'll spell out the details as best I can.)
From my main project directory I run:
npm install --save graphcool
This returns:
echo Run graphcool init to get started
Run graphcool init to get started
[email protected] /Users/samueldickerman/bhswriter_ultra
└── [email protected]
npm WARN [email protected] No repository field.
Then I try
graphcool init
and I get
✖ Error: Unexpected token p in JSON at position 0
When I run
npm version
I get
{ bhswriter: '0.1.0',
npm: '3.10.10',
ares: '1.10.1-DEV',
http_parser: '2.7.0',
icu: '58.2',
modules: '48',
node: '6.11.4',
openssl: '1.0.2l',
uv: '1.11.0',
v8: '5.1.281.108',
zlib: '1.2.11' }
The package.json file at the root of my project is:
{
"name": "bhswriter",
"version": "0.1.0",
"description": "bhswriter",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sam Dickerman",
"license": "ISC",
"dependencies": {
"axios": "^0.16.2",
"express": "^4.16.2",
"graphcool": "^1.3.7",
"sqlite3": "^3.1.13",
"vue": "^2.5.2"
}
}
Could you try upgrading your node version to 8+? 🙂 I believe 1.3.7 does not support versions <8.
Upgrade complete. Still some issues:
I uninstalled graphcool then reinstalled. From my project root I ran:
npm install --save graphcool
this returns:
echo Run graphcool init to get started
Run graphcool init to get started
npm WARN [email protected] No repository field.
- [email protected]
added 122 packages in 13.17s
Now I tried
graphcool init
this returns:
â–¸ Error parsing plugin
â–¸ /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-coreâ–¸ 'MODULE_NOT_FOUND': Cannot find module 'minimatch'
â–¸ Error parsing plugin
â–¸ /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-coreâ–¸ 'MODULE_NOT_FOUND': Cannot find module 'minimatch'
â–¸ Error parsing plugin
â–¸ /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-coreâ–¸ 'MODULE_NOT_FOUND': Cannot find module 'minimatch'
â–¸ init is not a graphcool command.
â–¸ Perhaps you meant help
â–¸ Run graphcool help for a list of available commands.
Upgrade complete
what's your node version now? 🙂
{ bhswriter: '0.1.0',
npm: '5.5.1',
ares: '1.10.1-DEV',
cldr: '31.0.1',
http_parser: '2.7.0',
icu: '59.1',
modules: '57',
nghttp2: '1.25.0',
node: '8.6.0',
openssl: '1.0.2l',
tz: '2017b',
unicode: '9.0',
uv: '1.14.1',
v8: '6.0.287.53',
zlib: '1.2.11' }
Oh - I noticed in all of my fumblings that I had graphcool installed in two places.
I'm on a mac and I'm using the usr folder as the root of all this (my name).
So from here I have my project folder AND at the same level a node_modules folder. At one point in my struggles I ran an install of graphcool with the -g command so I think that put it in the top level. But I deleted that at some point because there is no graphcool folder there now.
So in summary, right now in the root of my account I have:
bhswriter_ultra (my project folder where I have been trying to install and init graphcool)
/node_modules
/ graphcool <<=== this exists
node_modules
/ graphcool <<=== was there from past efforts but is now deleted.
Also - I forgot to include the top line from the install. So I ran this from my project folder:
npm install --save graphcool
and got this back:
[email protected] postinstall /Users/samueldickerman/bhswriter_ultra/node_modules/graphcool
echo Run graphcool init to get started
I notice this IS in the project folder.
I've unistalled and reinstalled as best I can and keep getting the error.
So to recap:
I install in project root:
npm install --save graphcool
[email protected] postinstall /Users/samueldickerman/bhswriter_ultra/node_modules/graphcool
echo Run graphcool init to get startedRun graphcool init to get started
npm WARN [email protected] No repository field.
- [email protected]
added 122 packages in 8.694s
I try to init graphcool but get an error:
graphcool init
â–¸ Error parsing plugin /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-coreâ–¸ 'MODULE_NOT_FOUND': Cannot find module 'minimatch'
â–¸ Error parsing plugin /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-core
â–¸ 'MODULE_NOT_FOUND': Cannot find module 'minimatch'
â–¸ Error parsing plugin /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-core
â–¸ 'MODULE_NOT_FOUND': Cannot find module 'minimatch'
â–¸ init is not a graphcool command.
â–¸ Perhaps you meant help
the package.json in the root of my project reads:
{
"name": "bhswriter",
"version": "0.1.0",
"description": "bhswriter",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sam Dickerman",
"license": "ISC",
"dependencies": {
"axios": "^0.16.2",
"express": "^4.16.2",
"graphcool": "^1.3.7",
"sqlite3": "^3.1.13",
"vue": "^2.5.2"
}
}
When I try and bring graphcool into my project via the app.js file like this:
var express = require('express')
var app = express()
var graphcool = require('graphcool');// static file serving
app.use(express.static(__dirname + '/public', {
index: "index.htm"
}));// initialize REST API
var REST = require("./server/REST.js");
REST.initialize(app);// start application
app.listen(3000, function() {
console.log('Listening on port 3000...')
})
I get this error:
module.js:529
throw err;
^Error: Cannot find module 'graphcool'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.(/Users/samueldickerman/bhswriter_ultra/app.js:3:17)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start:node app.js "app.js"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start 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! /Users/samueldickerman/.npm/_logs/2017-10-17T19_57_41_496Z-debug.log
Sorry for the trouble - thanks for any additional help!!
First, the 'minimatch' error indicates that you are still using the globally installed (beta) version, instead of the version in the project folder, because the path shows as /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-core.
I would advise you to uninstall the local and parent version, and just use the globally installed version, to prevent conflicts.
Second, why do you want to do require('graphcool') in your code? Are you maybe confusing it with graphcool-lib?
Third, the JSON error indicates a problem with your global .graphcool or .graphcoolrc file, that contains your token. Can you delete that file from ~/ and rerun graphcool auth? This is caused by a different file format between 1.3.7 and the beta.
I would advise you to uninstall the local and parent version, and just use the globally installed version, to prevent conflicts.
Great advice - I finally got that right.
Second, why do you want to do require('graphcool') in your code? Are you maybe confusing it with graphcool-lib?
Let's just say I don't know what I'm doing : )
Third, the JSON error indicates a problem with your global .graphcool or .graphcoolrc file, that contains your token. Can you delete that file from ~/ and rerun graphcool auth?
I did that and it worked!
Well, the installer hung up on the recent change that requires the @model
But I found this other thread here and used the trick posted by alassiter of doing this:
graphcool init --schema something.graphql --name _________
This made a new project for me on your site - but I'm fine with that - I hadn't really gotten started anyway.
Thank you so much for your patience and guidance today! I am an old web developer from the 90's (think asp and cfml) so all of this new technology has my head spinning. There were no such thing as a REST APIs when I was doing serious coding and now I'm skipping right to the latest and greatest.
Thanks again!
Most helpful comment
Great advice - I finally got that right.
Let's just say I don't know what I'm doing : )
I did that and it worked!
Well, the installer hung up on the recent change that requires the @model
But I found this other thread here and used the trick posted by alassiter of doing this:
This made a new project for me on your site - but I'm fine with that - I hadn't really gotten started anyway.
Thank you so much for your patience and guidance today! I am an old web developer from the 90's (think asp and cfml) so all of this new technology has my head spinning. There were no such thing as a REST APIs when I was doing serious coding and now I'm skipping right to the latest and greatest.
Thanks again!