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

TypeError: Path must be a string. Received undefined #2

Open
asparkam opened this issue Aug 23, 2017 · 1 comment
Open

TypeError: Path must be a string. Received undefined #2

asparkam opened this issue Aug 23, 2017 · 1 comment

Comments

@asparkam
Copy link

When i try to use localstorage in my isomorphic app:

const localStoraged = createLocalStorage();
localStorage.setItem("key", "12321321");

In sever console is:


path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:695:5)
    at resolve (path\to\project\server.js:65280:22)
    at module.exports.module.exports (path\to\project\server.js:6
5187:20)
    at Object.<anonymous> (path\to\project\server.js:65174:18)
    at Object.<anonymous> (path\to\project\server.js:65175:30)
    at __webpack_require__ (path\to\project\server.js:21:30)
    at createLocalStorage (path\to\project\server.js:65147:23)
    at Object.<anonymous> (path\to\project\server.js:6184:102)
    at __webpack_require__ (path\to\project\server.js:21:30)

Searching for this issue shows widespread problems with different libraries where path strings are being asserted instead of returning empty string if null. Suggestions were to downgrade to Node 5 or 4 from 6 (I do not wish to so this).

NPM version:
3.10.8
Node version:
v6.9.1
Node architecture:
x64
OS:
Windows 7

@azu azu added the Type: Bug label Aug 23, 2017
@azu
Copy link
Owner

azu commented Aug 23, 2017

Thanks for report.
Probably, It seem that app-root-path return undefined. This is a bug. I will look into it.

const appRoot = require('app-root-path');

( node-localstorage rquire store path )

You can avoid this issue by storeFilePath options.

const localStoraged = createLocalStorage({ 
     storeFilePath: __dirname + "/local-storage"
});
localStorage.setItem("key", "12321321");

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

2 participants