Rules_nodejs: Node library with native dependency fails to install

Created on 30 Jul 2019  路  2Comments  路  Source: bazelbuild/rules_nodejs

馃悶 bug report

Affected Rule

The issue is caused by the rule: npm_install. Note that it succeeds if yarn_install is used.

Is this a regression?

Yes, the previous version in which this bug was not present was: 0.16.2. I haven't checked versions in between though.

Description

Including a library with native dependency (I used grpc as example) makes npm_install fail whereas yarn_install still works.

馃敩 Minimal Reproduction

  1. Run npx @bazel/create example
  2. Include "grpc": "latest" into devDependencies of package.json
  3. Run bazel query @npm//...

馃敟 Exception or Error


Error: Cannot find module '../'
    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:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object. (/Users/vmax/work/GraknLabs/nodejsrepro/uuu/node_modules/grpc/node_modules/.bin/node-pre-gyp:15:20)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787: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)

馃實 Your Environment

Operating System:

  
        macOS Mojave 10.14.5
  

Output of bazel version:

  
Build label: 0.26.1
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Jun 6 11:08:11 2019 (1559819291)
Build timestamp: 1559819291
Build timestamp as int: 1559819291
  

Rules version (SHA):

  
`0.34.1` `7c4a690268be97c96f04d505224ec4cb1ae53c2c2b68be495c9bd2634296a5cd`
  

Anything else relevant?

npm ERR! A complete log of this run can be found in: (attached file)
2019-07-30T12_45_49_513Z-debug.log

bug

All 2 comments

I ran into the same issue using yarn_install and had to set preserve_symlinks = False in my node_repositories rule.

It seems node-pre-gyp is relying on a require statement being resolved from the realpath of the binfile, not from the symlink path.

dupe #506 I think - native modules is something scal.io team is planning to contribute

Was this page helpful?
0 / 5 - 0 ratings