Cannot find module 'now' - nowjs and nodejs - node.js

I installed nodejs in my home folder (/home/myname/). No problems so far.
Then I installed nowjs and there was one warning:
Checking for node path: not found
Now when I try this example: http://nowjs.com/doc/example I get the error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^ Error: Cannot find module 'now'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (/var/www/www.mydomain.de/htdocs/helloworld_server.js:7:13)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
Something with the paths is wrong I guess...anyone knows how to fix this?
Thanks

try this before :
npm config set global true && \
echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.bashrc && \
. ~/.bashrc

Related

Cannot find module 'm3u8stream/lib/parse-time'

is there anyway to fix this? I've been trying to resolve this myself but I give up
throw err;
^
Error: Cannot find module 'm3u8stream/lib/parse-time'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/rbd/pnpm-volume/71b5ddd8-2a78-46fc-aba4-68049f14880d/node_modules/.registry.npmjs.org/ytdl-core/1.0.0/node_modules/ytdl-core/lib/info-extras.js:5:21)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
This works for me, at the root of the project:
cp -r ./node_modules/m3u8stream/dist ./node_modules/m3u8stream/lib
I really don't understand why, I assume is some bug of versions, (mentioned in the previous comments) cause for some reason it needs the both folders dist and lib (with the same content apparently)
Solved by: Chills
Comment: did you install parse-time?
Answer: no I didn't, I did get it installed but also I've learned from a friend about ytdl-core update required dist instead of lib
Source: https://github.com/fent/node-ytdl-core/pull/520
Solution:
packages needed installing: m3u8stream and parse-time
code needed in main file:
const m3u8stream = require('m3u8stream');
const parseTime = require('m3u8stream/dist/parse-time');

Custom dependency require Electron

With the package.json, it's possible to do something like this
"dependencies": {
"WindowManager": "./lib/WindowManager"
},
But when trying to do this in Electron, it gives me this error:
App threw an error during load
Error: Cannot find module 'WindowManager'
at Module._resolveFilename (module.js:470:15)
at Function.Module._resolveFilename (.../desktop/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (.../desktop/lib/init.js:15:35)
at Object.<anonymous> (.../desktop/lib/init.js:22:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
Is it because of Electron, or am I doing something wrong?
./lib/WindowManager is a folder with a package.json in it with a main pointing to the WindowManager.js, so that should work.
The case you try to do normally works, make sure that the dependency "WindowManager" has been properly copied by the build tools to either:
.../desktop/node_modules/electron/dist/Electron.app/Contents/Resources/app.asar/node_modules
or
.../desktop/node_modules/electron/dist/Electron.app/Contents/Resources/node_modules
If WindowManager does not exist in the disted node_modules there is something wrong with your build process, hard to be more precise than that.

Webpack.config alias resolves during build but not during page load

I'm new to webpack and trying to work with some of the scaffoldings out there.
I'm trying to add an alias to the webpack config.
resolve: {
alias: {
'_utils': path.join(PATH_SRC, '/utils'),
},
}
It resolves fine during the build:
./src/utils/debounce.js
But the alias path doesn't get resolved when I try to load the page in the browser.
I feel like I must be missing something basic... Do I maybe need to pass these settings through to the hot-loader or something?
Here's the error I get
GET / 500 238.910 ms - 882
Error: Cannot find module '_utils/debounce'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/.../src/www/routes/RootRoute/CodeRoute/Component.js:23:17)
at Module._compile (module.js:425:26)
at loader (/.../node_modules/babel-register/lib/node.js:127:5)
at Object.require.extensions.(anonymous function) [as .js] (/.../node_modules/babel-register/lib/node.js:137:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
There is a demo repo here:
https://github.com/erchaves/example-app/tree/config-resolve-alias-example
(use npm run dev)
With notes in this commit:
https://github.com/erchaves/example-app/commit/3486b230a3188df19fcdcbb8f9401d2b4b8400e9
Thanks!

gulp command not combining JavaScript files in Laravel framework. Gives strange error

I have the following elixir function in Laravel framework:
var elixir = require('laravel-elixir');
elixir(function(mix) {
mix.sass('app.scss');
mix.styles(['bootstrap.min.css','app.css'], null, 'public/css');
mix.scripts(['bootstrap.min.js','jquery.min.js'], null, 'public/js');
mix.version('public/css/all.css');
});
The null parameters are supposed to automatically create all.css in public/css folder and all.js in public/js folder. While the css file is combined properly I get the following error for javascript files:
[12:53:30] 'scripts' errored after 952 ms
[12:53:30] Error: Cannot find module '../internal/assignWith'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/htdocs/t2ci/node_modules/laravel-elixir/node_modules/gulp-babel/node_modules/babel-core/node_modules/lodash/object/assign.js:1:80)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
[12:53:30] Error in plugin 'run-sequence'
Message:
An error occured in task 'scripts'.
I've wasted several hours searching the internet for solutions but I haven't found any yet. Would anyone have encountered this sort of error?
Your node_modules might be corrupted. Does it work properly after rm -rf node_modules && npm install?

Basic db-mysql setup error

I just started using node.js for my project and tried making a connection to MySQL and inserting basic values. But I keep getting the following error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Unable to load shared library /Users/****/nodeJS/node_modules/db-mysql/build/Release/mysql_bindings.node
at Object..node (module.js:472:11)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/Users/****/nodeJS/node_modules/db-mysql/db-mysql.js:18:15)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
I did as was instructed, I specified the MYSQL_CONFIG environment variable:
$ export MYSQL_CONFIG=/usr/local/mysql/bin/mysql_config
maybe it's too late and I hope you solved this problem on your own, but it might be useful for other people experiencing the same issue.
What I did to solve it is to set the following variable:
export DYLD_LIBRARY_PATH=<your absolute path to mysql lib folder>
in my case it is:
export DYLD_LIBRARY_PATH=/usr/local/mysql-5.5.25-osx10.6-x86_64/lib/
Tested on MacOS Lion 10.7.4

Resources