allcount / allcountjs

Rapid application development framework for Node.js
http://allcountjs.com
MIT License
402 stars 83 forks source link

Allcountjs not initializing the application #147

Open fadyhashmi opened 7 years ago

fadyhashmi commented 7 years ago

I am having issue init allcountjs applications

allcoutjs>allcountjs init
Enter application name [helloworld-app]: test
Enter author name: faahd
Enter author email:
Enter description:
Initializing "test" application using "twenty-two-lines" template...
   create : test
   create : test\app-config
   create : test\package.json
C:\Users\Fahad\AppData\Roaming\npm\node_modules\allcountjs-cli\bin\allcount.js:85
                body.files.forEach(function (file) {
                    ^

TypeError: Cannot read property 'files' of undefined
    at Request._callback (C:\Users\Fahad\AppData\Roaming\npm\node_modules\allcountjs-cli\bin\allcount.js:85:21)
    at self.callback (C:\Users\Fahad\AppData\Roaming\npm\node_modules\allcountjs-cli\node_modules\request\request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (C:\Users\Fahad\AppData\Roaming\npm\node_modules\allcountjs-cli\node_modules\request\request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)

node -v is v6.9.1 and npm -v 3.10.8

Alexey8127 commented 7 years ago

The reason is certificate has expired, as workaround you can use this solution http://stackoverflow.com/a/21961005, it's not secure, but works, you can use it something like this in allcount.js file:

mkdir(path.join(appName, 'app-config'), function () {
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
    request.post('https://allcountjs.com/api/app-template-for-cli-init', {json: packageJson}, function (err, httpResponse, body) {
        var fileCounter = 0;
        if (err || httpResponse.statusCode != 200) {
            console.log("error: " + err);
            if (httpResponse) {
                console.log("response: " + httpResponse.statusCode + " " + httpResponse.body);
            }
        } else body.files.forEach(function (file) {
            write(path.join(appName, 'app-config', file.fileName), file.content, 0666, function () {
                fileCounter++;
                if (body.files.length === fileCounter) {
                    var prompt = launchedFromCmd() ? '>' : '$';
                    console.log();
                    console.log('   install dependencies:');
                    console.log('     %s cd %s && npm install', prompt, appName);
                    console.log();
                    console.log('   run the app:');
                    var mongoUrl = "mongodb://localhost:27017/" + appName;
                    if (launchedFromCmd()) {
                        console.log('     %s SET DB_URL=%s:* & npm start', prompt, mongoUrl);
                    } else {
                        console.log('     %s DB_URL=%s:* npm start', prompt, mongoUrl);
                    }
                    console.log();
                    console.log('   or');
                    console.log('     %s allcountjs run', prompt);
                    console.log();
                }
            });
        });
    })
})
cristiandan commented 7 years ago

@Alexey8127 So where is all this code going? in the node_module for the global allcountjs-cli ?

Alexey8127 commented 7 years ago

@cristiandan yes, you can try to check the allcount.js path in error message, like in the first message:

Initializing "test" application using "twenty-two-lines" template...
   create : test
   create : test\app-config
   create : test\package.json
C:\Users\Fahad\AppData\Roaming\npm\node_modules\allcountjs-cli\bin\allcount.js:85
                body.files.forEach(function (file) {
.............
hipparchus2000 commented 7 years ago

I have a similar issue, but I suspect it is because I am behind a proxy. Googling for it I can't find a specific way to set up allcount to use a proxy.

badlee commented 6 years ago

just type

NODE_TLS_REJECT_UNAUTHORIZED=0 allcountjs init