Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

requires not working on node v5.2.0 #481

Closed
Anthonyzou opened this issue Dec 14, 2015 · 10 comments
Closed

requires not working on node v5.2.0 #481

Anthonyzou opened this issue Dec 14, 2015 · 10 comments

Comments

@Anthonyzou
Copy link

For some reason doing a simple require('zmq') will fail to import. It will lead to a cannot find module error. However a require('./node_modules/zmq') works fine.

@ronkorving
Copy link
Collaborator

Sounds more like a problem in your project than in zmq... Mind sharing a bit more about your file structure and package.json information?

@Anthonyzou
Copy link
Author

There is literally nothing in the project (it just started) except for zmq and requires only a simple npm install for zmq. The code is doing nothing interesting except trying to require zmq. Switching to node to v4.2.3 has no problem with a require('zqm').

{
  "name": "fordan",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "dependencies": {
    "zmq": "^2.14.0"
  }
}

@ronkorving
Copy link
Collaborator

Projects rk$ mkdir zmq-test
Projects rk$ cd zmq-test
zmq-test rk$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (zmq-test) 
version: (1.0.0) 
description: 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /Users/rk/Projects/zmq-test/package.json:

{
  "name": "zmq-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this ok? (yes) 
zmq-test rk$ npm i --save zmq
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
-
> [email protected] install /Users/rk/Projects/zmq-test/node_modules/zmq
> node-gyp rebuild

  SOLINK_MODULE(target) Release/zmq.node
ld: warning: directory not found for option '-L/opt/local/lib'
[email protected] node_modules/zmq
├── [email protected]
└── [email protected]
zmq-test rk$ echo 'require("zmq");' > index.js
zmq-test rk$ node index.js 
zmq-test rk$ 

@ronkorving
Copy link
Collaborator

zmq-test rk$ node index.js
zmq-test rk$ node --version
v5.2.0

@ronkorving
Copy link
Collaborator

Are you perhaps forgetting to re-install zmq between Node major versions? You have to rebuild the binary, because Node's internal API is not compatible between major versions.

@Anthonyzou
Copy link
Author

That's weird because I built zmq with node v5.2 and it works fine with v4.2. Anyways, there is just something wrong with the 5.2 distribution because it won't load any modules. Thanks though!

@ronkorving
Copy link
Collaborator

Good luck

@Anthonyzou
Copy link
Author

Oh found out for some reason the node v5.2 REPL will not load modules from the node_modules folder.

@reqshark
Copy link
Contributor

guys.. It's not zeromq. I was having problems with 5.2 require in the node REPL with fedor's ip module. I think it's a node problem

@reqshark
Copy link
Contributor

btw that got fixed in 5.3 nodejs/node#4215

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

No branches or pull requests

3 participants