Can't Start Work. #18

Closed
opened 2020-04-16 09:51:54 +00:00 by Ghost · 4 comments

Good day. I'm tring to start greenlock code:

"use strict";
var pkg = require('./package.json');
var Greenlock = require('greenlock');
var greenlock = Greenlock.create({
    configDir: './greenlock.d/config.json',
    packageAgent: pkg.name + '/' + pkg.version,
    maintainerEmail: pkg.author,
    staging: true,
    notify: function(event, details) {
        if ('error' === event) {
            console.error(details);
        }
    }
});

but recive an error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:120:11)
    at Object.resolve (path.js:980:7)
    at Object.Init._init (/root/myre_webchat/node_modules/@root/greenlock/lib/init.js:129:14)
    at Object.greenlock._create (/root/myre_webchat/node_modules/@root/greenlock/greenlock.js:58:22)
    at Object.G.create (/root/myre_webchat/node_modules/@root/greenlock/greenlock.js:482:15)
    at Object.<anonymous> (/root/myre_webchat/idx.js:5:27)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14) {
  code: 'ERR_INVALID_ARG_TYPE'
}

How can I avoid this error?

Good day. I'm tring to start greenlock code: ``` "use strict"; var pkg = require('./package.json'); var Greenlock = require('greenlock'); var greenlock = Greenlock.create({ configDir: './greenlock.d/config.json', packageAgent: pkg.name + '/' + pkg.version, maintainerEmail: pkg.author, staging: true, notify: function(event, details) { if ('error' === event) { console.error(details); } } }); ``` but recive an error: ``` TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at validateString (internal/validators.js:120:11) at Object.resolve (path.js:980:7) at Object.Init._init (/root/myre_webchat/node_modules/@root/greenlock/lib/init.js:129:14) at Object.greenlock._create (/root/myre_webchat/node_modules/@root/greenlock/greenlock.js:58:22) at Object.G.create (/root/myre_webchat/node_modules/@root/greenlock/greenlock.js:482:15) at Object.<anonymous> (/root/myre_webchat/idx.js:5:27) at Module._compile (internal/modules/cjs/loader.js:1123:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10) at Module.load (internal/modules/cjs/loader.js:972:32) at Function.Module._load (internal/modules/cjs/loader.js:872:14) { code: 'ERR_INVALID_ARG_TYPE' } ``` How can I avoid this error?
Author
var greenlock = Greenlock.create({
    configDir: './greenlock.d',
    packageAgent: pkg.name + '/' + pkg.version,
    maintainerEmail: pkg.author,
    staging: true,
    packageRoot: __dirname,
    notify: function(event, details) {
        if ('error' === event) {
            // `details` is an error object in this case
            console.error(details);
        }
    }
});

this will fix your issue

```js var greenlock = Greenlock.create({ configDir: './greenlock.d', packageAgent: pkg.name + '/' + pkg.version, maintainerEmail: pkg.author, staging: true, packageRoot: __dirname, notify: function(event, details) { if ('error' === event) { // `details` is an error object in this case console.error(details); } } }); ``` this will fix your issue
Owner

Yes, the important change is that configDir should be a directory, not a file:

    // this will NOT work
    configDir: './greenlock.d/config.json',
    // this is correct
    configDir: './greenlock.d',
Yes, the important change is that `configDir` should be a directory, not a file: ``` // this will NOT work configDir: './greenlock.d/config.json', ``` ``` // this is correct configDir: './greenlock.d', ```
Owner

Closing because I believe this resolve this issue, but please re-open if not.

Closing because I believe this resolve this issue, but please re-open if not.
Author

Yes, the important change is that configDir should be a directory, not a file:

    // this will NOT work
    configDir: './greenlock.d/config.json',
    // this is correct
    configDir: './greenlock.d',

Thanks I it still works with configDir being configDir: './greenlock.d/config.json' it considers /config.json as folder path. it was missing packageRoot: __dirname,

> Yes, the important change is that `configDir` should be a directory, not a file: > > > ``` > // this will NOT work > configDir: './greenlock.d/config.json', > ``` > > ``` > // this is correct > configDir: './greenlock.d', > ``` Thanks I it still works with configDir being configDir: '```./greenlock.d/config.json```' it considers /config.json as folder path. it was missing ```packageRoot: __dirname,```
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: root/greenlock.js#18
No description provided.