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

Error: Cannot find module 'memdown' #413

Closed
Leen15 opened this issue Feb 10, 2016 · 15 comments
Closed

Error: Cannot find module 'memdown' #413

Leen15 opened this issue Feb 10, 2016 · 15 comments

Comments

@Leen15
Copy link

Leen15 commented Feb 10, 2016

Hi, i'm using mosca with a custom dockerfile, where I install node and mosca as follow:

....
# Install nodejs and helpful node packages
RUN apt-get install nodejs -y --force-yes
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN apt-get install npm -y --force-yes

#Install PostgresSQL client
RUN apt-get install libpq-dev -y --force-yes

# Install Redis.
...
RUN mkdir -p $PROJECT_PATH
COPY . $PROJECT_PATH
WORKDIR $PROJECT_PATH

RUN npm install debug
RUN npm install mosca@latest --save
RUN npm install daemon
RUN npm install bcrypt
RUN npm install jsonwebtoken
RUN npm install pg
RUN npm install pg-native
....

Every time i rebuild the docker image it installs version 0.32.1 of mosca.
So i added @latest to mosca npm module and now it installs correct version 1.0.2.
But when i start the container it doesn't stay up, and i read in log this error:

module.js:340
    throw err;
    ^
Error: Cannot find module 'memdown'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/mosca_project/node_modules/mosca/lib/persistence/memory.js:29:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Any Ideas?

@mcollina
Copy link
Collaborator

which version of node are you using?
Il giorno mer 10 feb 2016 alle 12:45 Luca notifications@github.com ha
scritto:

Hi, i'm using mosca with a custom dockerfile, where I install node and
mosca as follow:

....

Install nodejs and helpful node packages

RUN apt-get install nodejs -y --force-yes
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN apt-get install npm -y --force-yes

#Install PostgresSQL client
RUN apt-get install libpq-dev -y --force-yes

Install Redis.

...
RUN mkdir -p $PROJECT_PATH
COPY . $PROJECT_PATH
WORKDIR $PROJECT_PATH

RUN npm install debug
RUN npm install mosca@latest --save
RUN npm install daemon
RUN npm install bcrypt
RUN npm install jsonwebtoken
RUN npm install pg
RUN npm install pg-native
....

Every time i rebuild the docker image it installs version 0.32.1 of mosca.
So i added @latest https://github.com/latest to mosca npm module and
now it installs correct version 1.0.2.
But when i start the container it doesn't stay up, and i read in log this
error:

module.js:340
throw err;
^
Error: Cannot find module 'memdown'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/mosca_project/node_modules/mosca/lib/persistence/memory.js:29:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

Any Ideas?


Reply to this email directly or view it on GitHub
#413.

@Leen15
Copy link
Author

Leen15 commented Feb 10, 2016

Hi Matteo, aptitude installs node 0.10.25.

@mcollina
Copy link
Collaborator

I would suggest at least 0.10.36 on the 0.10.x line. But I'd suggest you to
use v4.
Il giorno mer 10 feb 2016 alle 13:46 Luca notifications@github.com ha
scritto:

Hi Matteo, aptitude installs node 0.10.25.


Reply to this email directly or view it on GitHub
#413 (comment).

@Leen15
Copy link
Author

Leen15 commented Feb 10, 2016

I already tried to use v4 but with no luck:

daemon@1.1.0 node_modules/daemon
 ---> 70745de75307
Removing intermediate container 15c969ac98bb
Step 22 : RUN npm install bcrypt

> bcrypt@0.8.5 install /mosca_project/node_modules/bcrypt
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:116:14)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:49:11
gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16)
gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:93:16
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Linux 3.13.0-63-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mosca_project/node_modules/bcrypt
gyp ERR! node -v v4.3.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "bcrypt"
npm ERR! node v4.3.0
npm ERR! npm  v2.14.12
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.5 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mosca_project/npm-debug.log
The command '/bin/sh -c npm install bcrypt' returned a non-zero code: 1

@psorowka
Copy link
Contributor

I am pretty sure that in either case your npm install doesn't run cleanly. Have a look at the output of the docker build.

In your pasted code for node4 it says: gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. So obviously you are missing python in the docker base image you are using.

So the better question would probably be: what Docker base image are you using?

@Leen15
Copy link
Author

Leen15 commented Feb 10, 2016

Ok so instead of use apt repo for install node i tried to use "n":

RUN npm install -g n
RUN n 0.10.36

With this version mosca working fine.

If instead i try to use last node version:

RUN npm install -g n
RUN n stable

I receive this error:

npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "mosca" "--save"
npm ERR! node v5.6.0
npm ERR! npm  v3.6.0
npm ERR! path /mosca_project/node_modules/debug
npm ERR! code EXDEV
npm ERR! errno -18
npm ERR! syscall rename

npm ERR! EXDEV: cross-device link not permitted, rename '/mosca_project/node_modules/debug' -> '/mosca_project/node_modules/.debug.DELETE'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /mosca_project/npm-debug.log
The command '/bin/sh -c npm install mosca --save' returned a non-zero code: 238

Base image is ubuntu:14.04, with build-essential installed (for install redis).

Thanks for support guys.

@Leen15
Copy link
Author

Leen15 commented Feb 10, 2016

I'm trying with various versions.
With node 4.0.0 all working fine, with node 5.6.0 give the error above, with node 5.2.0 it give this error:

make: Leaving directory `/mosca_project/node_modules/zmq/build'
make: *** [Release/obj.target/zmq/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:88:13)
gyp ERR! stack     at ChildProcess.emit (events.js:173:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:201:12)
gyp ERR! System Linux 3.13.0-63-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mosca_project/node_modules/zmq
gyp ERR! node -v v5.2.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:zmq@2.14.0 zmq@2.14.0 install: `node-gyp rebuild`
npm WARN install:zmq@2.14.0 Exit status 1

But container start and mosca working.
What version of node should i use? I'm not expert of node (i don't know if you did notice yet? :P )

@mcollina
Copy link
Collaborator

if you are not using zmq there is nothing to worry about.

@Leen15
Copy link
Author

Leen15 commented Feb 10, 2016

Ok so i stay with node 5.2.
Thanks for all :)

@jdkanani
Copy link

Getting same error with node v5.6.0

@jdkanani
Copy link

It's npm problem: deleting ~/.npm, npm_modules and installing dependencies did the trick.

@uchobby
Copy link

uchobby commented Mar 6, 2016

I am having this problem with mosca not finding memdown. memdown is installed and in the node_modules directory. I am trying to run the basic example with no backend DB so it should use internal memory...

Here is the code...

var mosca = require('mosca')

var moscaSettings = {
port: 1883,
};

var server = new mosca.Server(moscaSettings);
server.on('ready', setup);

server.on('clientConnected', function(client) {
console.log('client connected', client.id);
});

// fired when a message is received
server.on('published', function(packet, client) {
console.log('Published', packet.payload);
});

// fired when the mqtt server is ready
function setup() {
console.log('Mosca server is up and running')
}


node version...

node --version
v0.10.25


Run the code....

node server.js


result

module.js:340
throw err;
^
Error: Cannot find module 'memdown'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/root/MQTTBroker/node_modules/mosca/lib/persistence/memory.js:29:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

@uchobby
Copy link

uchobby commented Mar 6, 2016

I did not mean for the formatting on that to yell out.. with bold type etc... sorry, markdown false trigger..LOL

@mcollina
Copy link
Collaborator

mcollina commented Mar 6, 2016

So, update your version of NPM and node. Something went wrong in your installation phase.
And do not use the node.js version from your linux distribution.

@mcollina mcollina closed this as completed Mar 6, 2016
@rgstephens
Copy link

Pulling my hair out on this one. I've tried the latest 0.12 release and had this error, saw that @mcollina recommended v4, so I'm now on v4.4.3 and still have this error. I've avoided installing the standard Ubuntu package as recommended. Not sure where to go next.

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

6 participants