Error: Cannot find module './_freeGlobal' - node.js

Error: Cannot find module './_freeGlobal'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
When I try to delete this module, there is a message that I cannot find another module. Almost all modules are not found

I just had this same issue in a React app. I simply ran npm install in my project folder and that fixed the problem.

Related

''adonis' is not recognized as an internal or external command' problem even though I installed the CLI globally

My Windows 10 PC forces me to install CLI and assign environment varriables (happens when I install ionic). This time, same trouble with Adonis. First, the problem is 'adonis' is not recognized as an internal or external command'
To solve this, I have installed Adonis locally in C:\Users\mq003\AppData\Local\node_modules. Which I receive is the only #Adonis directory and it doesn't come with a .cmd file so I can't use this. Therefore, I imported directly the cli from github with npm i -save #adonisjs/cli and copy the .cmd files in npm directory, while others will be put in node_modules (because my Path declare I put the cmd there).
As you can see, all ngrok, ionic, etc. commands belong here. They all work perfectly fine in every terminals.
When I try to type adonis commands, this time, it said.
PS D:\adonis project> adonis --help
internal/modules/cjs/loader.js:626
throw err;
^
Error: Cannot find module 'C:\Users\mq003\AppData\Roaming\#adonisjs\cli\index.js'
?[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:527:27)?[39m
?[90m at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)?[39m
?[90m at internal/main/run_main_module.js:17:11?[39m {
code: ?[32m'MODULE_NOT_FOUND'?[39m,
requireStack: []
}
I think it requires #adonisjs directory outside, not in node_modules. So I get that directory out (as you can see in the picture). However, the error still exists.
Editted: I found an issue posted on Github seems relevant to my problem. I will link here in case it helps.
Github

Error: Cannot find module '/Applications/Atom.app/***/electron.asar/browser/init.js' while attaching debugger to nodejs

I'm trying to debug my node script using atom-node-debugger plugin.
Below are the commands I used to start the node script -
When I try to attach the debugger I am getting below error -
throw err;
Error: Cannot find module '/Applications/Atom.app/Contents/Frameworks/Atom Helper.app/Contents/Resources/electron.asar/browser/init.js'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:473:25)
at Function.Module.runMain (module.js:683:10)
at startup (bootstrap_node.js:196:16)
at bootstrap_node.js:622:3
Process exited (Port: 9229 (Node attach))
How can I resolve this error?
Am I missing something?
As mentioned in the error, that file does not exist. In the most recent version of Atom (1.38.x at the time of this writing), the file electron.asar is located at Atom.app/Contents/Resources, but not inside the Atom Helper.app.
There are several issues open on GitHub with a similar error. Looks like the package is outdated and no longer actively maintained.

Cannot find module: Ember-template-compiler after upgrading to 2.12.1

After upgrading to Ember cli 2.12.1 I receive the following error, when trying to serve ember.
Cannot find module 'C:\Users\assaue\web\client\bower_components\ember\ember-template-compiler'
Error: Cannot find module 'C:\Users\assaue\web\client\bower_components\ember\ember-template-compiler'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Class.htmlbarsOptions (C:\Users\assaue\web\client\node_modules\emberx-file-input\node_modules\ember-cli-htmlbars\ember-addon-main.js:72:25)
at Object.toTree (C:\Users\assaue\web\client\node_modules\emberx-file-input\node_modules\ember-cli-htmlbars\ember-addon-main.js:31:43)
at C:\Users\assaue\web\client\node_modules\ember-cli-preprocess-registry\preprocessors.js:180:26
at Array.forEach (native)
at processPlugins (C:\Users\assaue\web\client\node_modules\ember-cli-preprocess-registry\preprocessors.js:178:11)
at module.exports.preprocessTemplates (C:\Users\assaue\web\client\node_modules\ember-cli-preprocess-registry\preprocessors.js:161:10)
Try updating below in package.json
"ember-cli-htmlbars-inline-precompile": "^0.3.6"
Maybe any one of your addons might expect ember to be installed through bower.
I think some of your addon listed in package.json requires ember js to be in bower directory. For my app, the addon was jquery-ui and it was referred as following.
templateCompilerPath = this.project.bowerDirectory + '/ember/ember-template-compiler';
Add
"ember": "2.13.0" ( Latest Version now )
in bower.json
Ember has moved ember package from bower to npm as ember-source, but still it doesn't work as expected because of third party addons
when you don't have ember package in bower.json.
You may get WARNING: Ember.js is now provided by node_moduleember-source, please remove it from bower in terminal when you run your ember app.
I am pretty sure that the problem is in the emberx-file-input module judging from your log.
at Class.htmlbarsOptions (C:\Users\assaue\web\client\node_modules\emberx-file-input\node_modules\ember-cli-htmlbars\ember-addon-main.js:72:25)
Key fragment is \emberx-file-input\node_modules\ember-cli-htmlbars
It doesn't have the correct ember-cli-htmlbars yet and hence it throws the error. Try to find the version of the emberx-file-input which has the correct dependency.

How to load node modules in beaker notebook?

I'm using beaker notebook and would like to use some external node modules - yet because beaker doesn't change the system path to the directory of the currently active file, my attempts to include stream-filter are met with the error:
Error: Cannot find module 'stream-filter'
Error: Cannot find module 'stream-filter'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at eval (eval at processCode (/opt/homebrew-cask/Caskroom/beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/app.js:45:23), :5:14)
at processCode (/opt/homebrew-cask/Caskroom/beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/app.js:45:18)
at /opt/homebrew-cask/Caskroom/beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/app.js:32:28
at callbacks (/opt/homebrew-cask/Caskroom/beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/node_modules/express/lib/router/index.js:164:37)
at param (/opt/homebrew-cask/Caskroom/beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/node_modules/express/lib/router/index.js:138:11)
at pass (/opt/homebrew-cask/Caskroom/beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/node_modules/express/lib/router/index.js:145:5)
I'm wondering how to solve this problem. I tried process.chdir('/Users/akivalipshitz/Developer/Computational_Linguistics') to no avail, even though stream-filter is installed in node_modules in the same directory.
So how do people use node modules
The context where the node code is eval'd is in your case
/opt/homebrew-cask/Caskroom//beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/app.js
So require() looks for a module in the node_modules folder there and then recursively up along the parent folders (see docs).
One solution (if you're only working on one project or use this module frequently across all your projects) would be to install your module there:
cd /opt/homebrew-cask/Caskroom//beaker/1.4.2-1-ge55c059/Beaker.app/Contents/Resources/dist/config/plugins/eval/node/app/
npm install stream-filter
Another (ugly) approach could be to build a long relative path in your require(). In your case something like:
require('../../../../../../../../../../../../Users/akivalipshitz/Developer/Computational_Linguistics');
Both cases it would mean that your code is not portable to another beaker instance. However, at least until a better solution is proposed this could get you along prototyping.
as of this writing, the current version of Beaker allows you to import npm modules right from the GUI. Just click notebook -> Language Manager -> Javascript, then type the module names into Loaded Libraries. Beaker autocompletes from the npm registry.
This works both in the electron client and the cloud hosted version.

Problems with running node module

So, I am getting the infamous error:
module.js:340
throw err;
^
Error: Cannot find module '/home/bc/projects/nodejs/pg-connect.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
here is the 2 line source causing it:
var pg = require('pg');
console.log("Hello world!");
Before asking for help here I have tried several things all of which didn't work:
1)I tried setting it to the absolute path, in my case:
var pg = require(/home/bc/node_modules/pg);
2)I tried copy/paste the above directory into my project directory.
3) I tried to install the module locally using:
npm install pg
However instead of the current directy it installed in the path /hone/bc/node_modules
I have no idea what more I can try to get it to work.
As I mention in my comment, it appears that you've successfully installed the module, but in the wrong place.
A quick fix would be to copy the contents of HOMEDIR/node_modules into CURRENTDIR/node_modules.
Then you should be able to
var pg=require('pg');
To find "require-able" modules, Node will check the current directory for its module directory, unsuprisingly named "node_modules", and if it cannot find the module there, Node will move back up the directory path until it either finds a node_modules directory containing the required module or it hits the root. So, assuming your current directory is /home/bc/projects/nodejs, Node will look for the pg module in the following directories (in order):
/home/bc/projects/nodejs/node_modules/pg
/home/bc/projects/node_modules/pg
/home/bc/node_modules/pg
/home/node_modules/pg
/node_modules/pg

Resources