Skip to content

TypeError: Path must be a string. Received null #1041

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

Closed
ghost opened this issue Sep 21, 2016 · 5 comments
Closed

TypeError: Path must be a string. Received null #1041

ghost opened this issue Sep 21, 2016 · 5 comments
Labels
bug current functionality does not work as desired help wanted

Comments

@ghost
Copy link

ghost commented Sep 21, 2016

Description

ava nor ava --init nor ava --version is working.
The project has no config at all and no node_modules.
ava is installed globaly

Error Message & Stack Trace

d:\repositories\git\crmintern\Testing_Ground>ava --version                                                                                                                             
path.js:7                                                                                                                                                                              
    throw new TypeError('Path must be a string. Received ' + inspect(path));                                                                                                           
    ^                                                                                                                                                                                  

TypeError: Path must be a string. Received null                                                                                                                                        
    at assertPath (path.js:7:11)                                                                                                                                                       
    at Object.dirname (path.js:697:5)                                                                                                                                                  
    at Object.<anonymous> (C:\Users\stefan.schneider\AppData\Roaming\npm\node_modules\ava\cli.js:43:19)                                                                                
    at Module._compile (module.js:556:32)                                                                                                                                              
    at Object.Module._extensions..js (module.js:565:10)                                                                                                                                
    at Module.load (module.js:473:32)                                                                                                                                                  
    at tryModuleLoad (module.js:432:12)                                                                                                                                                
    at Function.Module._load (module.js:424:3)                                                                                                                                         
    at Module.runMain (module.js:590:10)                                                                                                                                               
    at run (bootstrap_node.js:394:7)                                                                                                                                                   
    at startup (bootstrap_node.js:149:9)                                                                                                                                               
    at bootstrap_node.js:509:3  

Command-Line Arguments

Copy your npm build scripts or the ava command used:

ava --version

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

node: v6.6.0
ava: v0.16.0
npm: 3.10.8
VSCode Version: Code 1.5.2 (66f37fd2a99eb9d628dd374d81d78835b410c39b, 2016-09-12T13:30:03.456Z)
OS Version: Windows_NT ia32 10.0.10586
@novemberborn
Copy link
Member

That's this line:

var pkgDir = path.dirname(pkgConf.filepath(conf));

That changed in #925. Looks like AVA now won't start without a package.json present. We use that file (or rather the directory it's in) to figure out various paths. I suggest that without it we just use the current working directory.

@novemberborn novemberborn added bug current functionality does not work as desired help wanted labels Sep 21, 2016
@ghost
Copy link
Author

ghost commented Sep 21, 2016

okay, package.json needs to be around AND it must be a valid JSON as well so an empty file doesn't fit.

@sotojuan
Copy link
Contributor

sotojuan commented Sep 21, 2016

Changing the line to this:

var pkgDir;

try {
  pkgDir = path.dirname(pkgConf.filepath(conf));
} catch (error) {
  pkgDir = process.cwd();
}

Fixed the issue for me. Good for a PR?

@ghost
Copy link
Author

ghost commented Sep 21, 2016

Would be good if a package.json would be created in the cwd if it is not there

@novemberborn
Copy link
Member

Would be good if a package.json would be created in the cwd if it is not there

I'd say that's up to you. ava init should just add to the existing package, not create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired help wanted
Projects
None yet
Development

No branches or pull requests

2 participants