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

Can't install PrimeCMS on my Windows PC #328

Closed
JeremieLeblanc opened this issue Sep 4, 2019 · 7 comments
Closed

Can't install PrimeCMS on my Windows PC #328

JeremieLeblanc opened this issue Sep 4, 2019 · 7 comments

Comments

@JeremieLeblanc
Copy link

After running these two commands on my windows pc:

> npm install -g @primecms/cli
> primecms init my-project

I enter the name of the project, postgres username, password and database.
Then it crashes with this:

C:\Users\Jeremie-Desktop\AppData\Roaming\npm\node_modules\@primecms\cli\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
        throw ex;
        ^

Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)

It does create the folder with some files, namely:

  • .editorconfig
  • .env
  • .gitignore
  • app.json
  • index.js
  • package.json
  • README.md

I then run "yarn" to install the packages.
Followed by "primecms start"

At this point I do get this:

prime:core building schema +0ms
prime:graphql building schema +0ms
prime:server � Server ready at http://localhost:4000/prime/graphql +0ms
prime:server � Subscriptions ready at ws://localhost:4000/graphql +0ms

When I go to http://localhost:4000/graphql I do get the playground, but if I go to http://localhost:4000 I get a "Network Error" after a few seconds.

When I check the console, similarly to #224, I get:

Could not parse prime config SyntaxError: Unexpected token W in JSON at position 251
    at JSON.parse (<anonymous>)
    at Module.1101 (main.529cbcdc.chunk.js:1)
    at f (localhost/:1)
    at Object.532 (main.529cbcdc.chunk.js:1)
    at f (localhost/:1)
    at a (localhost/:1)
    at Array.e [as push] (localhost/:1)
    at main.529cbcdc.chunk.js:1

Which makes sense because a config file was never generated...
I have tried every installation methods and none of them work on my PC, I have similarly tried on a mac without issues.

@birkir
Copy link
Owner

birkir commented Sep 4, 2019

Can you try the manual installation?

You can use either yarn or npm.

npm init
npm install -S @primecms/core @primecms/ui

createdb prime

@JeremieLeblanc
Copy link
Author

After running createdb prime I get:

createdb: command not found

@birkir
Copy link
Owner

birkir commented Sep 4, 2019

You need to install postgres 👍

(and have the tools in PATH https://stackoverflow.com/questions/11460823/setting-windows-path-for-postgres-tools)

@JeremieLeblanc
Copy link
Author

That's my bad I didn't have it in my PATH, ok I did that and it does create an empty db called prime.

What are the next steps?
I now have a folder with a node_modules, a package.json and package-lock.json
As well as an empty database called prime.

@olek-pastukhov
Copy link

olek-pastukhov commented Oct 26, 2019

I have also experienced such problem with JSON parsing:

Could not parse prime config SyntaxError: Unexpected token W in JSON at position 251
    at JSON.parse (<anonymous>)
    at Module.1101 (main.529cbcdc.chunk.js:1)
    at f (localhost/:1)
    at Object.532 (main.529cbcdc.chunk.js:1)
    at f (localhost/:1)
    at a (localhost/:1)
    at Array.e [as push] (localhost/:1)
    at main.529cbcdc.chunk.js:1

This happening due to the windows paths parsing. Seems to be you are not testing up&run on windows PC.

the buggy code located here:

let config = get(window, 'prime.config', '');
let coreUrl = isProd ? '/' : 'http://localhost:4000';
const fields: any = [];
let env: any = {};

try {
 
  // parsing brakes at processing win path like C:\project\prime_cms\ 
  config = JSON.parse(config);
 
  coreUrl = config.coreUrl || coreUrl;
  env = config.env || env;
} catch (err) {
  if (isProd) {
    console.error('Could not parse prime config', err); // tslint:disable-line no-console
  }
}

@olek-pastukhov
Copy link

I have found a root cause.
You have to fix the code in file serveUI (e.g. with adding one extra stringify and remove redundant quotes) at line:

res.send(data.toString().replace('"$PRIME_CONFIG$"', `${  JSON.stringify( JSON.stringify(config))}`));

also in file fields.js it would be better to use more universal regexp:

.replace(/\/?\\?package.json$/, '');

@robvenn
Copy link

robvenn commented Feb 21, 2020

For me this also didn't work on Windows, I just tried to clone the repository and then entered yarn install and then yarn run setup but it fails trying to link the packages :
error An unexpected error occurred: "ENOENT: no such file or directory, stat 'C:\\Users\\robin\\AppData\\Local\\Yarn\\Data\\link\\@primecms\\cli\\lib\\index.js'". so might not work cross-env or I'must be doing something wrong, some suggestions:

  • improve documentation if possible
  • use cross-env scripts or use containers

I'd be glad to help out if I can

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

No branches or pull requests

4 participants