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

const pkg = require('./package'); #266

Closed
alanzhaonys opened this issue Jan 22, 2017 · 4 comments
Closed

const pkg = require('./package'); #266

alanzhaonys opened this issue Jan 22, 2017 · 4 comments

Comments

@alanzhaonys
Copy link

v6.7.1

const pkg = require('./package');

this line is causing issue. "package" is not defined in package.json

ERROR in .//is-online//is-reachable/~/got/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./package in /Users/alan/Desktop/Electron/app/node_modules/is-online/node_modules/is-reachable/node_modules/got
resolve file
/Users/alan/Desktop/Electron/app/node_modules/is-online/node_modules/is-reachable/node_modules/got/package doesn't exist
/Users/alan/Desktop/Electron/app/node_modules/is-online/node_modules/is-reachable/node_modules/got/package.js doesn't exist
/Users/alan/Desktop/Electron/app/node_modules/is-online/node_modules/is-reachable/node_modules/got/package.jsx doesn't exist
resolve directory

@sindresorhus
Copy link
Owner

package is package.json. Extensions are optional.

@hugohil
Copy link

hugohil commented Apr 28, 2017

I leave that here because it can help people facing similar issue.

I was having an issue with the got module (through vue-resource) like this:

ERROR in ./~/got/index.js
Module not found: Error: Can't resolve './package' in '/path/to/project/node_modules/got'

I found that the issue was caused by webpack not resolving the extension automatically, so I added this to my webpack.config.js file:

resolve: {
    extensions: ['.js', '.json']
}

so now I can omit the .json extension when I require() a module.

Hope this helps someone :)

@GabeDuarteM
Copy link

@hugohil Sir, you helped me a lot with this, i was having this './package' error, and your fix solved it!

@spiritOfSasidhar
Copy link

I leave that here because it can help people facing similar issue.

I was having an issue with the got module (through vue-resource) like this:

ERROR in ./~/got/index.js
Module not found: Error: Can't resolve './package' in '/path/to/project/node_modules/got'

I found that the issue was caused by webpack not resolving the extension automatically, so I added this to my webpack.config.js file:

resolve: {
    extensions: ['.js', '.json']
}

so now I can omit the .json extension when I require() a module.

Hope this helps someone :)

i am facing same issue, but i didnt have webpack file in my project, so please give appropriate solution

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

No branches or pull requests

5 participants