npm ReferenceError: primordials is not defined (node.js) - javascript

I know this question is posted many times but I tried the solutions and I can not resolve it. I am trying to work wit npm however I get this error:
evalmachine.<anonymous>:35
} = primordials;
^
ReferenceError: primordials is not defined
at evalmachine.<anonymous>:35:5
at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:8)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:3:27)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
I can not even execute npm -v to see the version.
I tried to downgrade node to version 10.
I tried to uninstall-reinstall node so many times (From remove application settings).
I tried to create a file called "npm-shrinkwrap.json" insde the npm folder where package.json exists.
But there is no use.
And I can't see an "AppData" folder in the "Users/User" path but I can access it by "cd" from the command line. I don't understand how it is not visible.
Thank you.

It is resolved!
I know I said I uninstalled npm, but just uninstalling it from the settings were not enough. I tried to uninstall it deleting the node releted directories on my computer following this post: https://stackoverflow.com/a/11178106/13806114. And then I installed node again and it worked!
Thank you.

It's looking for the "primordials" method in graceful-fs, trying to reinstall this dependency.
About npm, try reinstalling nodejs again, probably your npm is corrupted
About AppData is not visible or is a hidden directory in Windows, you can access it by path in Windows Explorer

Related

Cannont find module 'node-fetch'

I've been trying to run the code but it just shows this error i couldn't fix it because i'm not into coding that much i'm just trying to run the app
here's the error
Uncaught Error Error: Cannot find module 'node-fetch'
Require stack:
- c:\Users\As\Desktop\tiktok-downloader-main\index.js
at Module._resolveFilename (internal/modules/cjs/loader:956:15)
at Module._load (internal/modules/cjs/loader:804:27)
at Module.require (internal/modules/cjs/loader:1028:19)
at require (internal/modules/cjs/helpers:102:18)
at <anonymous> (c:\Users\As\Desktop\tiktok-downloader-main\index.js:6:15)
at Module._compile (internal/modules/cjs/loader:1126:14)
at Module._extensions..js (internal/modules/cjs/loader:1180:10)
at Module.load (internal/modules/cjs/loader:1004:32)
at Module._load (internal/modules/cjs/loader:839:12)
at executeUserEntryPoint (internal/modules/run_main:81:12)
at <anonymous> (internal/main/run_main_module:17:47)
Try looking for a file called package-lock.json in the tiktok-downloader-main folder. It could be in any of the sub folders. Once you find it, navigate to that folder in your terminal and run - npm install.
If you do not find the file called package-lock.json, look for yarn.lock file. If you find this file - in your terminal run yarn install.
These commands will work if you already have npm/yarn installed. For both of them, you will need nodejs installed.
Moreover, these commands have been tested on a Mac. Windows machine commands should be similar, but I do not gaurantee that these commands will work on windows machines as well.

Electron Native Addon: Version missmatch

I am trying to create a simple example Native addon for Electron. However, keep running into this version miss match issue. I have .nvmrc files for both my electron project and the addon project (using node 7.4.0).
Electron 1.6.7
Node 7.4.0
Nvm 0.33.2
NPM 4.0.5
The Error
App threw an error during load
Error: The module '/Users/mikepriest/source/Browser/exambrowser-electron/app/native/prebuilt/addon/build/Release/native_rt.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/mikepriest/source/Browser/exambrowser-electron/app/main.dev.js:20:10)
at Object.<anonymous> (/Users/mikepriest/source/Browser/exambrowser-electron/app/main.dev.js:217:3)
Tried solutions
1. Tried using
./node_modules/.bin/electron-rebuild
2. Tried rebuilding my addon
nvm use 7.4.0
npm rebuild
Still get the error.
Update: found this post, but solution didn't work for me either.

Yeoman : angular-fullstack-generator cannot find module 'babel-runtime/helpers/interop-require-default'

i've been trying to use Yeoman to scaffold a mean app with angular-fullstack-generator, however i've been encountering this weird error i'd never encountered before, i've already tried reinstalling grunt-cli, npm, yo, none of it works, i'm using NVM and Node 4.4.0
I have Python 2.7.11 installed, apparently the 32-bit version, whereas everything else is 64-bit, i don't know if this might be what's causing the problem.
The full description of the error as shown on the console is as follows:
yo angular-fullstack
module.js:327
throw err;
^
Error: Cannot find module 'babel-runtime/helpers/interop-require-default'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\Jonny\AppData\Roaming\npm\node_modules\generator-angular-fullstack\node_modules\babel-register\lib\node.js:3:30)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
So, what am i doing wrong here? Is there anything else i can try to fix the problem?
The error occurs because the babel-runtime module is missing. The babel-runtime module is required for babel to work.
You can fix this by running the command:
npm install --save babel-runtime
I solved it uninstalling and removing babel from node global dependencies and then reinstalling yo and generatog-angular-fullstack.
I had a similar error, it couldn't find gulp-babel, so I installed the module globally.
$ npm install -g --save gulp-babel
And if you're using a mac you may want to try to put sudo in front of the command.

GithubElectron: A JavaScript error occured in the browser process

I installed "electron-packager" using npm and executed the command
electron-packager . Johnston --platform=darwin --arch=x64 --version=0.36.0
And then I when I run the "Johnston.app", this error showed up (I didn't even see the main window)
Uncaught Exception: Error: Cannot find module 'electron'
at Function.Module._resolveFilename (module.js:332:15)
at Function.Module._load (module.js:282:25)
at Module.require (module.js:361:17)
at require (module.js:380:17)
at Object. (/Users/David/Github/Johnston/Johnston-darwin-x64/Johnston.app/Contents/Resources/app/main.js:3:18)
at Module._compile (module.js:426:26)
at Object.Module._extensions..js (module.js:444:10)
at Module.load (module.js:351:32)
at Function.Module._load (module.js:306:12)
at Object. (/Users/David/Github/Johnston/Johnston-darwin-x64/Johnston.app/Contents/Resources/atom.asar/browser/lib/init.js:104:10)
Is there any solutions? Thanks!
This likely has something to do with you having a different version of Electron installed on your machine that you are using to build with. In the folder for your app, run electron --version to get the version of electron that you have installed. Then, change the --version=0.36.0 to use whatever version you have installed.
If that doesn't fix it, then you should try rm -rf node_modules && npm install on your project. This will remove you node modules and then reinstall them all. If that doesn't work, please comment here and I will try to help again.

Cannot find module 'sails'

I am trying to run a sails application with Webstorm 7.0.3.
this appear when i try to run the server in the console log:
module.js:340
throw err;
^
Error: Cannot find module 'sails'
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. (C:\Users**\projects\WebstormProjects**\app.js:2:1)
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.runMain [as _onTimeout] (module.js:497:10)
Process finished with exit code 8
i installed sails globaly. i know that this is dont work because it cant find the sails module in the project's local 'node_modules' directory. if ill install again 'sails' localy it will work. but i dont want to...
Is there a way to make it work with sails global install? thanks!
The sails module that your code is looking for is not the same thing as the sails command you're executing at the terminal.
The command generates project skeletons. The module is the code that actually makes it run.
You need to install the command globally and the module locally.
Global installation (using npm install -g) does not make modules available globally to all node applications, it's only there for command line stuff.
If your applications relies on Sails, you should have it in your dependencies in package.json as well as installed locally.
If you don't like the way that npm creates a copy of each module locally, use yarn and tell it to symlink the cached version.

Categories