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 · 1 comment
Open

Cannot find module from directory with index file #253

samrith-s opened this issue Nov 5, 2019 · 1 comment
Labels
bug

Comments

@samrith-s
Copy link

@samrith-s samrith-s commented Nov 5, 2019

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

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Nov 5, 2019

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.

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.