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

Syntax error issues on preact create #165

Closed
bobc82 opened this issue Jun 30, 2017 · 7 comments
Closed

Syntax error issues on preact create #165

bobc82 opened this issue Jun 30, 2017 · 7 comments

Comments

@bobc82
Copy link

bobc82 commented Jun 30, 2017

I tried to run the preact-cli installation as follows:

sudo npm i -g preact-cli

And preact-cli was installed as expected. After, i tried to create a project:

sudo preact create example-app

On the first attempt terminal returned the following Syntax Error:

/usr/local/lib/node_modules/preact-cli/node_modules/webpack-plugin-replace/lib/index.js:9
	let i=0, len=arr.length, map=new Map();
	^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/preact-cli/lib/lib/webpack/webpack-base-config.js:25:29)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/preact-cli/lib/lib/webpack/webpack-client-config.js:39:26)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/preact-cli/lib/lib/webpack/run-webpack.js:27:28)

I tried to fix myself this issue adding on top of /usr/local/lib/node_modules/preact-cli/node_modules/webpack-plugin-replace/lib/index.js file:

"use strict";

In the second attempt, the preact create command fired another Syntax error, as follows:

/usr/local/lib/node_modules/preact-cli/node_modules/devcert-san/dist/index.js:22
function devcert(appName, options = {}) {
                                  ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/preact-cli/lib/lib/ssl-cert.js:5:19)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/preact-cli/lib/commands/watch.js:9:16)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/preact-cli/lib/index.js:16:14)

The platform where i'm attempting to create the preact project is Ubuntu 16.04.

@rkostrzewski
Copy link
Collaborator

Could please provide us with your node version (node -v) ?

@bobc82
Copy link
Author

bobc82 commented Jun 30, 2017

v4.2.6

@thangngoc89
Copy link
Collaborator

@bobc82 we only support Node.js >= 6.0 (current LTS). Please update your node version

@developit
Copy link
Member

Also I'd recommend avoiding sudo - it's setting all the permissions wrong for everything you install, and gives root access to arbitrary code downloaded from the internet. There's a great guide that walks you through removing the sudo requirement.

@reznord
Copy link
Member

reznord commented Jun 30, 2017

It would be great to add a check for minimum requirements before we run preact create

@bobc82
Copy link
Author

bobc82 commented Jun 30, 2017

I upgraded node at the latest version and now preact create runs fine. And i'll try to reconfigure all avoiding 'sudo'. Thank you everyone!

@bobc82 bobc82 closed this as completed Jun 30, 2017
@thangngoc89
Copy link
Collaborator

@bobc82 quick tip: Use nvm to manage your node version. No need for manual config

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

5 participants