Uncaught TypeError: Cannot read property 'local' of undefined in chrome extension
Make sure that all necessary permissions have been declared in the manifest file. "storage"
, in your case.
In general, the following steps should fix the problem of apparently undefined Chrome APIs:
- Read the documentation of the API you're using and get yourself familiar with the prerequisites, usually manifest permissions (e.g.
chrome.storage
#manifest). - Check if your (user's) Chrome version supports the API, by looking at What's new.
- Check if the script is running in the right context. Most APIs are only available to the extension's process. (the
chrome.storage
API can also be used in content script though) - Otherwise, resort to your usual debugging skills: Typos, variable shadowing, ...