node installed but npm is not installed - node.js

Problem
node -v is working but,
npm -v is not working, error
Error encountered
C:\Users\HackerGprat>node -v
v19.2.0
C:\Users\HackerGprat>npm -v
node:internal/modules/cjs/loader:1039
const err = new Error(message);
^
Error: Cannot find module '../package.json'
Require stack:
- C:\Users\HackerGprat\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\HackerGprat\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
←[90m at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)←[39m
←[90m at Module._load (node:internal/modules/cjs/loader:885:27)←[39m
←[90m at Module.require (node:internal/modules/cjs/loader:1105:19)←[39m
←[90m at require (node:internal/modules/cjs/helpers:103:18)←[39m
at createEnginesValidation ←[90m(C:\Users\HackerGprat\←[39mAppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:7:15←[90m)←[39m
at module.exports ←[90m(C:\Users\HackerGprat\←[39mAppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:73:27←[90m)←[39m
at Object.<anonymous> ←[90m(C:\Users\HackerGprat\←[39mAppData\Roaming\npm\node_modules\←[4mnpm←[24m\bin\npm-cli.js:2:25←[90m)←[39m
←[90m at Module._compile (node:internal/modules/cjs/loader:1218:14)←[39m
←[90m at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:1081:32)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [
←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
]
}
Node.js v19.2.0
Try : 1
walkthrough installation
👆 my doubt is i did not checked ☑ the options of automatic install necessary tools becuase it will take lots of mb so i skiped it.. and by default it was unchecked too [ ]
it did not working, and given me error,
Try : 2
it's working on sandbox but not in real pc.
Try : 3
tried to copy all installation folder from sandbox to real pc,
node -v -> working
npm -v -> not working, error
Try : 4
Trying without installing node, copied from sandbox
node -v -> working
npm -v -> not working, error
Try : 5
Tried to change the location with new name NJS
node -v -> working
npm -v -> not working, error

Try 6 : Successfully Installed npm
as you can see the last line
requireStack: [
←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
]
its pointing to AppData folder,
and saying there is npm folder
just delete that npm folder and reinstall the node
and see it started again working..
results

Related

No definite solution on Windows for Cannot find module 'graceful-fs' Error on React Native App Create Start Up

`PS C:\Users\Adrien\Documents\ReactNativeProjects> npx react-native start
node:internal/modules/cjs/loader:1042
throw err;
^
Error: Cannot find module 'graceful-fs'
Require stack:
- C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js
- C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at _gracefulFs (C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:15:39)
at Object.<anonymous> (C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:22:1) at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Adrien\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\gracefulifyFs.js',
'C:\\Users\\Adrien\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}
Node.js v18.13.0
Everytime I tried to create an App I got this as a response.
I tried to Open a Project like,
npx react-native init App2
I was expecting was for the project to get built, appear so that I could see all the project files.
I tried uninstalling and then reinstalling like,
npm install 'graceful-fs'
I tried the other solutions here too like apt-get or sudo and curl but it didn't work in my terminal`

pod install fails in integrated vs terminal

I'm trying to run a pod update from my integrated VS-code terminal (react-native project) but it keeps throwing this error:
node:internal/modules/cjs/loader:936 throw err; ^
Error: Cannot find module '/Users/.../App/node_modules/#react-native-community/cli/build/bin.js Debugger attached. Waiting for the debugger to disconnect...'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
Node.js v17.6.0
[!] Invalid `Podfile` file: 859: unexpected token at ''.
target 'appname' do
config = use_native_modules! use_react_native!(
I already tried removing package-lock.json, node_modules, and reinstalling.
If I run the command in a normal terminal I have no problems, any ideas?
Please try this:
step 1: pod deintegrate
step 2: pod install

Error: Cannot find module 'code-point-at' while writing any npm commands

Configurations:
System : Ubuntu v21.10
node : v16.14.0
npm : v6.13.7
Problem :
It was working well until last ubuntu software update,Now its throwing "Error: Cannot find module 'code-point-at' while writing any npm commands" because of code: 'MODULE_NOT_FOUND'
I have attached terminal Screenshot,please help me solve this issue.
Terminal:
Terminal Screenshot
ssns#nits-hp-15-notebook-pc:~$ npm --version
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module 'code-point-at'
Require stack:
- /usr/lib/node_modules/npm/node_modules/wide-align/node_modules/string-width/index.js
- /usr/lib/node_modules/npm/node_modules/wide-align/align.js
- /usr/lib/node_modules/npm/node_modules/gauge/lib/render-template.js
- /usr/lib/node_modules/npm/node_modules/gauge/lib/plumbing.js
- /usr/lib/node_modules/npm/node_modules/gauge/lib/index.js
- /usr/lib/node_modules/npm/node_modules/npmlog/lib/log.js
- /usr/lib/node_modules/npm/lib/utils/log-shim.js
- /usr/lib/node_modules/npm/lib/utils/exit-handler.js
- /usr/lib/node_modules/npm/lib/cli.js
- /usr/lib/node_modules/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/wide-align/node_modules/string-width/index.js:3:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/lib/node_modules/npm/node_modules/wide-align/node_modules/string-width/index.js',
'/usr/lib/node_modules/npm/node_modules/wide-align/align.js',
'/usr/lib/node_modules/npm/node_modules/gauge/lib/render-template.js',
'/usr/lib/node_modules/npm/node_modules/gauge/lib/plumbing.js',
'/usr/lib/node_modules/npm/node_modules/gauge/lib/index.js',
'/usr/lib/node_modules/npm/node_modules/npmlog/lib/log.js',
'/usr/lib/node_modules/npm/lib/utils/log-shim.js',
'/usr/lib/node_modules/npm/lib/utils/exit-handler.js',
'/usr/lib/node_modules/npm/lib/cli.js',
'/usr/lib/node_modules/npm/bin/npm-cli.js'
]
}
ssns#nits-hp-15-notebook-pc:~$
Thanks in Advance.. :)
I have the same issue on Windows - even npm -v would throw the same error. I'm unable to find the root cause of the issue, but found the following workaround.
I found out that the folder at Program Files\nodejs\node_modules\npm\node_modules\code-point-at was empty for me, even after a clean install of Node. In your case, the directory should be /usr/lib/node_modules/npm/node_modules/code-point-at.
I downloaded a copy of code-point-at from its Github repository at https://github.com/sindresorhus/code-point-at/tags, and manually copied the files into the directory. Once this was done, NPM appears to function normally for me.

How do devs maintain old projects?

A year ago I've made a project for a course: https://github.com/GeorgeFlorian/Finished_link_project
Now, I am trying to make it work on my machine, but I have no luck.
I've got npm 7.13.0 and node 16.1.0.
I've ran npm update in order to update all the depencies.
Steps
I've cloned the repo into a PC than runs Linux Mint 20.1
I've ran npm install
npm update
npm run build and npm run serve return the same error:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project$ npm run build
> proiect-link#0.1.0 build
> vue-cli-service build
⠧ Building for production...
ERROR Failed to compile with 1 error 2:55:41 PM
Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR Build failed with errors.
I have no idea how to trace the error: Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined.
Also, the NodeJS server won't start:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project/server$ node app.js
node:internal/fs/utils:343
throw err;
^
Error: ENOENT: no such file or directory, stat '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
at Object.statSync (node:fs:1527:3)
at resolveSync (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:187:17)
at favicon (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:61:12)
at Object.<anonymous> (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/server/app.js:46:9)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
errno: -2,
syscall: 'stat',
code: 'ENOENT',
path: '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
}
I believe that many dependencies are deprecated, but this begs two questions:
If it worked back then and it hasn't been touched since, why doesn't it work now ?
How can I fix all the deprecated dependencies if npm update did not fix them ?
Ultimately, I would like to learn how to approach this kind of situation. Thank you.

NodeJS nodegui module could not be found

Attempting to get nodegui running on a blank nodeJS project, but it won't run. The example starter-project runs fine, however I do not want to use webpack on my project.
Error when running node main.js:
internal/modules/cjs/loader.js:1208
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: The specified module could not be found.
\\?\C:\Users\user\Documents\project\node_modules\#nodegui\nodegui\build\Release\nodegui_core.node
�[90m at Object.Module._extensions..node (internal/modules/cjs/loader.js:1208:18)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Module.require (internal/modules/cjs/loader.js:1044:19)�[39m
�[90m at require (internal/modules/cjs/helpers.js:77:18)�[39m
at Object.<anonymous> (C:\Users\user\Documents\project\node_modules\�[4m#nodegui�[24m\nodegui\dist\lib\utils\addon.js:3:15)
�[90m at Module._compile (internal/modules/cjs/loader.js:1158:30)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
main.js:
const { QMainWindow } = require("#nodegui/nodegui");
const win = new QMainWindow();
win.show();
global.win = win;
When running npm install #nodegui/nodegui this is the output.
Windows 10 x64 build 18363, NodeJS version 12.16.1, NPM version 6.14.2, NodeGUI version 0.16.0
npx qode main.js
or
npm exec qode main.js
It's seem specified module is missing in your project you need to run:
npm i --save specified

Resources