Protractor error 105 when trying to run spec.js

Per @jtzero's remark, the issue lies with the configuration parser masking the actual error message when loading the configuration file.

Depending on whether you run Protractor as global or from the folder, open up (C:\Users\y\AppData\Roaming\npm\)node_modules\protractor\built\configParser.js at line 13‌​0. There you can add logger.error(e); e.g:

    /**
     * Public function specialized towards merging in a file's config
     *
     * @public
     * @param {String} filename
     */
    ConfigParser.prototype.addFileConfig = function (filename) {
        if (!filename) {
            return this;
        }
        var filePath = path.resolve(process.cwd(), filename);
        var fileConfig;
        try {
            fileConfig = require(filePath).config;
        }
        catch (e) {
            logger.error(e);
            throw new exitCodes_1.ConfigError(logger, 'failed loading configuration file ' + filename);
        }
        if (!fileConfig) {
            throw new exitCodes_1.ConfigError(logger, 'configuration file ' + filename + ' did not export a config object');
        }
        fileConfig.configDir = path.dirname(filePath);
        this.addConfig_(fileConfig, fileConfig.configDir);
        return this;
    };

This will then report the error in the output. In my case it was a failing call to require():

[10:36:29] E/configParser - { [Error: Cannot find module 'phantomjs'] code: 'MODULE_NOT_FOUND' }

Repored GitHub issue #3301: https://github.com/angular/protractor/issues/3301

Update
Protractor 4.0 will include a fix for this problem to report the masked error message with a stack trace.


You should be running the conf.js file, not the spec.js file.

It looks like you are running the command "protractor spec.js" when it should be "protractor conf.js". The error says it is looking for a configuration file but you are passing it a spec file.


Passing correct path to conf.js file can be a solution. Try to navigate to folder, in which you have this file and then launch the command again.

Of course, point at conf.js file, not spec.

Tags:

Protractor