Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

TypeError: Cannot read property 'join' of undefined #1824

Closed
tnguyen14 opened this issue Dec 7, 2016 · 2 comments · Fixed by #1825
Closed

TypeError: Cannot read property 'join' of undefined #1824

tnguyen14 opened this issue Dec 7, 2016 · 2 comments · Fixed by #1825

Comments

@tnguyen14
Copy link
Contributor

I'm getting the following error when using node-sass programmatically:

/path/to/project/node_modules/node-sass/lib/index.js:177
  return options.includePaths.join(path.delimiter);
                             ^

TypeError: Cannot read property 'join' of undefined
    at buildIncludePaths (/path/to/project/node_modules/node-sass/lib/index.js:177:30)
    at getOptions (/path/to/project/node_modules/node-sass/lib/index.js:195:26)
    at Object.module.exports.render (/path/to/project/node_modules/node-sass/lib/index.js:282:17)

I've created a reduced test case as follow:

var sass = require('node-sass');

sass.render('main.scss', function (err, results) {
	if (err) {
		return console.error(err);
	}
	console.log(results.css);
});

with main.scss just contains

body {
	margin: 0;
}

I tried to add some console log to the buildIncludePaths function, and seeing the following output

/**
 * Build an includePaths string
 * from the options.includePaths array and the SASS_PATH environment variable
 *
 * @param {Object} options
 * @api private
 */

function buildIncludePaths(options) {
  console.log(options.includePaths);
  console.log(options.includePaths || []);
  options.includePaths = options.includePaths || [];
  console.log(options.includePaths);

  if (process.env.hasOwnProperty('SASS_PATH')) {
    options.includePaths = options.includePaths.concat(
      process.env.SASS_PATH.split(path.delimiter)
    );
  }

  return options.includePaths.join(path.delimiter);
}
undefined
[]
undefined
/path/to/project/node_modules/node-sass/lib/index.js:177
  return options.includePaths.join(path.delimiter);
                             ^

When reporting an bug, you must provide this information:

  • NPM version (npm -v): 3.10.9
  • Node version (node -v): v7.1.0
  • Node Process (node -p process.versions):
  node: '7.1.0',
  v8: '5.4.500.36',
  uv: '1.10.0',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  modules: '51',
  openssl: '1.0.2j',
  icu: '58.1',
  unicode: '9.0',
  cldr: '30.0.2',
  tz: '2016g' }
  • Node Platform (node -p process.platform): darwin
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"):
node-sass       3.13.0  (Wrapper)       [JavaScript]
libsass         3.3.6   (Sass Compiler) [C/C++]
@tnguyen14
Copy link
Contributor Author

I realized it was because I used the API incorrectly. My apologies.

@tnguyen14
Copy link
Contributor Author

FWIW, should there be a check somewhere that if the options is not an object, it should fail earlier?

jiongle1 pushed a commit to scantist-ossops-m2/node-sass that referenced this issue Apr 7, 2024
Update for GNUmakefile.am .editorconfig
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant