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

CLI --source-map option broken #1026

Closed
johnpolacek opened this issue Jul 8, 2015 · 9 comments
Closed

CLI --source-map option broken #1026

johnpolacek opened this issue Jul 8, 2015 · 9 comments

Comments

@johnpolacek
Copy link

In a new directory, create a test.scss file with one line of css, save then in CLI run:
node-sass test.scss test.css --source-map

You will get the following error:

var sourceMapIsDirectory = options.sourceMapOriginal.indexOf('.map', optio
TypeError: Object true has no method 'indexOf'
@am11
Copy link
Contributor

am11 commented Jul 10, 2015

This was a breaking change in v3, see #964.

In your case, use node-sass test.scss test.css --source-map true or node-sass test.scss test.css --source-map custom-path/to/whatever.map

@nhunzaker
Copy link

I just hit this as well and the error message is very cryptic. What do you think about improving the error here if a value isn't present?

@glassdimly
Copy link
Contributor

I am of the opinion that node-sass --help ought to note that --source-map needs a boolean parameter. Otherwise most people would reasonably assume that this was just a standard unix parameter that did not need a boolean, especially when --output is specified. The --help option also does not specify that a directory argument can be added to --source-map. It should not be necessary to google the error or read the source: that's what the --help or man page is for.

@sant123
Copy link

sant123 commented Sep 14, 2016

This error is still happening... I have this

  "scripts": {
    "ts" : "node_modules\\.bin\\tsc -w -p .",
    "sass_env" : "SET node-sass=node_modules\\.bin\\node-sass",
    "sass_compile" : "npm run sass_env && node-sass styles -o styles --output-style compressed --source-map ",
    "sass" : "npm run sass_compile && node-sass styles -wo styles --output-style compressed --source-map "
  }

When I execute npm run sass I get the following error:

D:\santiagoah\informacion\Desktop\Visor de documentos>npm run sass                                                                                                 

> visor-de-documentos@1.0.0 sass D:\santiagoah\informacion\Desktop\Visor de documentos                                                                             
> npm run sass_compile && node-sass styles -wo styles --output-style compressed --source-map                                                                                   


> visor-de-documentos@1.0.0 sass_compile D:\santiagoah\informacion\Desktop\Visor de documentos                                                                     
> npm run sass_env && node-sass styles -o styles --output-style compressed --source-map                                                                            


> visor-de-documentos@1.0.0 sass_env D:\santiagoah\informacion\Desktop\Visor de documentos                                                                         
> SET node-sass=node_modules\.bin\node-sass                                                                                                                        

D:\santiagoah\informacion\Desktop\Visor de documentos\node_modules\node-sass\bin\node-sass:209                                                                     
    var sourceMapIsDirectory = options.sourceMapOriginal.indexOf('.map', options.sourceMapOriginal.length - 4) === -1 && isDirectory(options.sourceMapOriginal);   
                                                         ^                                                                                                         

TypeError: options.sourceMapOriginal.indexOf is not a function                                                                                                     
    at getOptions (D:\santiagoah\informacion\Desktop\Visor de documentos\node_modules\node-sass\bin\node-sass:209:58)                                              
    at Object.<anonymous> (D:\santiagoah\informacion\Desktop\Visor de documentos\node_modules\node-sass\bin\node-sass:386:15)                                      
    at Module._compile (module.js:541:32)                                                                                                                          
    at Object.Module._extensions..js (module.js:550:10)                                                                                                            
    at Module.load (module.js:458:32)                                                                                                                              
    at tryModuleLoad (module.js:417:12)                                                                                                                            
    at Function.Module._load (module.js:409:3)                                                                                                                     
    at Module.runMain (module.js:575:10)                                                                                                                           
    at run (node.js:348:7)                                                                                                                                         
    at startup (node.js:140:9)  

re-open?

@AntonKL
Copy link

AntonKL commented Sep 16, 2016

Documentation says
--source-map => Emit source map

Accroding to this issue the correct syntax is to include a true after --source-map
--source-map true => Emit source map

Would suggest a update on docs.

@sant123
Copy link

sant123 commented Sep 16, 2016

Thank you @AntonKL It worked as expected!

@BenRacicot
Copy link

Docs still not updated. Thumbs up @AntonKL

escattone added a commit to mdn/kuma that referenced this issue Jan 17, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
escattone added a commit to mdn/kuma that referenced this issue Jan 21, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
escattone added a commit to mdn/kuma that referenced this issue Jan 24, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
escattone added a commit to mdn/kuma that referenced this issue Jan 26, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
escattone added a commit to mdn/kuma that referenced this issue Jan 26, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
escattone added a commit to mdn/kuma that referenced this issue Jan 30, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
jwhitlock pushed a commit to mdn/kuma that referenced this issue Jan 31, 2017
* Install node-sass in Dockerfile-base
* Update Makefile "echo" for "compilecss" step
* Update node-sass call to use "--source-map true"
  (see sass/node-sass#1026)
ascorbic pushed a commit to ascorbic/node-sass that referenced this issue May 8, 2018
It is not clear from the `--help` docs that `--source-map` requires a boolean or path. Passing the flag alone results in a TypeError. There's an argument to be made that passing the flag alone should imply `true`, or at the very least it should fail with a helpful error, not a cryptic TypeError. For now, this PR fixes the --help docs so that they match the README.
xzyfer pushed a commit that referenced this issue May 8, 2018
It is not clear from the `--help` docs that `--source-map` requires a boolean or path. Passing the flag alone results in a TypeError. There's an argument to be made that passing the flag alone should imply `true`, or at the very least it should fail with a helpful error, not a cryptic TypeError. For now, this PR fixes the --help docs so that they match the README.
@ZelphirKaltstahl
Copy link

5 years later, and the error message is still just as cryptic.

/root/app/node_modules/node-sass/bin/node-sass:208
    var sourceMapIsDirectory = options.sourceMapOriginal.indexOf('.map', options.sourceMapOriginal.length - 4) === -1 && isDirectory(options.sourceMapOriginal);
                                                         ^

TypeError: options.sourceMapOriginal.indexOf is not a function
    at getOptions (/root/app/node_modules/node-sass/bin/node-sass:208:58)
    at Object.<anonymous> (/root/app/node_modules/node-sass/bin/node-sass:376:15)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

@williamdes
Copy link

5 years later, and the error message is still just as cryptic.

One more year to the counter, seriously add some code handle this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants