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

Cannot find module from directory with index file #253

Open
samrith-s opened this issue Nov 5, 2019 · 4 comments
Open

Cannot find module from directory with index file #253

samrith-s opened this issue Nov 5, 2019 · 4 comments
Labels
bug need repro Need example to reproduce the bug.

Comments

@samrith-s
Copy link

Hey,

I've been using Bili for quite a few packages and it has worked well so far. We have our API, which uses ES6. It has a lot of index.js files, and we import them like so:

import resolvers from './resolvers'

And the resolvers/index.js is as follows:

import Query from './queries';
import Mutation from './mutations';
import types from './types';

export default {
    Query,
    Mutation,
    ...types
};

After the build, when I try running node build/server.js I get the error:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'resolvers'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/sam/Work/totem/systems/api/build/server.js:1:327)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Idk what I'm doing wrong here. I see you already have rollup-plugin-node-resolve included. I don't know why it's unable to find the file, and has not compiled it into the bundle.

Here is my bili.config.js:

module.exports = {
    input: 'src/server.js',
    output: {
        dir: 'build',
        fileName: '[name][min][ext]',
        format: 'cjs',
        minify: process.env.NODE_ENV === "production",
        sourceMap: true
    },
    bundleNodeModules: true,
    env: process.env.NODE_ENV
}

Everything builds properly, but I can't run it.

Thanks!

@issue-label-bot issue-label-bot bot added the bug label Nov 5, 2019
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.68. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@Rahulgarg30591
Copy link

@samrith-s Any update on this one? I am facing the very same issue.

@samrith-s
Copy link
Author

I’ve stopped using bili. Switched to webpack or TS for all of my project.

@fi3ework
Copy link
Collaborator

I'd like to fix this bug. I tried to reproduce this bug but I failed... Would like to provide a minimal repro repo?

@fi3ework fi3ework added the need repro Need example to reproduce the bug. label Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug need repro Need example to reproduce the bug.
Projects
None yet
Development

No branches or pull requests

3 participants