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

Simple express example not working #4

Open
mattmoor opened this issue Nov 28, 2017 · 2 comments
Open

Simple express example not working #4

mattmoor opened this issue Nov 28, 2017 · 2 comments

Comments

@mattmoor
Copy link

I am trying to put together a simple express example to try these out (since I've been able to get further with them than bazelbuild/rules_nodejs), and I'm running into an issue.

To reproduce (on top of standard WORKSPACE @ 4fe6494):

# Set up express dependency.
# see: https://github.com/dropbox/rules_node/issues/3
bazel run @org_dropbox_rules_node//node/tools/npm:gen_build_npm -- [email protected] $PWD/

I then append (adding node_binary to the load()):

node_binary(
    name = 'binary',
    srcs = ['index.js'],
    main = 'index.js',
    deps = [
        ':express',
    ],
)

However, when I bazel run :binary I'm getting:

$ bazel run :binary
INFO: Analysed target //:binary (0 packages loaded).
INFO: Found 1 target...
ERROR: /home/mattmoor/trying-node/BUILD:334:1: Creating runfiles tree bazel-out/local-opt/bin/binary.runfiles failed (Exit 1)
_bin/build-runfiles (args bazel-out/local-opt/bin/binary.runfiles_manifest bazel-out/local-opt/bin/binary.runfiles): paths must not be absolute: line 1: '/node_modules/express/History.md /home/mattmoor/.cache/bazel/_bazel_mattmoor/e6c1f9a612e03cb822c6e33f6e63f45c/execroot/__main__/bazel-out/local-opt/bin/node_modules/express/History.md'

Target //:binary failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.647s, Critical Path: 1.38s
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target

The contents of index.js don't even matter. Am I holding it wrong? Any workarounds?

Bazel version info:

$ bazel version
Build label: 0.7.0
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Oct 18 14:27:19 2017 (1508336839)
Build timestamp: 1508336839
Build timestamp as int: 1508336839
@samertm
Copy link
Contributor

samertm commented Nov 30, 2017

Ah, you've stumbled over a bug where npm_library rules don't work in your root BUILD file. I'll figure out what's going on, but in the meantime you can get this to work by putting the npm_library rule in a subfolder. At Dropbox, our convention is to put all npm modules in //npm, so express would go in //npm/express.

@rwatts3
Copy link

rwatts3 commented Jan 30, 2019

Was a solution ever determined for this issue ?

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

3 participants