I have reinstalled Windows and since then, I cannot use npm, I always face the following bug.
I have tried reinstalling node, switching its versions but the npm commands keeps failing.
$ npm
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module './utils/unsupported.js'
Require stack:
- C:\Users\Guillaume\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\Guillaume\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
←[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m
←[90m at Module.require (node:internal/modules/cjs/loader:999:19)←[39m
←[90m at require (node:internal/modules/cjs/helpers:102:18)←[39m
at module.exports (C:\Users\Guillaume\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:14:59)
at Object.<anonymous> (C:\Users\Guillaume\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\bin\npm-cli.js:2:25)
←[90m at Module._compile (node:internal/modules/cjs/loader:1099:14)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:975:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [
←[32m'C:\\Users\\Guillaume\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
←[32m'C:\\Users\\Guillaume\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
]
}
Node.js v17.8.0
Related
PS C:\Users\QHTF\Desktop\Statistics> npm
node:internal/modules/cjs/loader:985
const err = new Error(message);
^
Error: Cannot find module './internal/re'
Require stack:
C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js
C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\lib\cli.js
C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object. (C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js:2:20)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js',
'C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\lib\cli.js',
'C:\Users\QHTF\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js'
]
}
First you need to install modules according to your node project. It should be very convenient if you use any control panel. You can install it from Module(s)>Manage section.
$ npx create-react-app counter
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'block-stream'
Require stack:
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\lib\entry-writer.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\lib\pack.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\tar.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app\node_modules\tar-pack\index.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app\index.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. (C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\lib\entry-writer.js:7: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: [
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar\lib\entry-writer.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar\lib\pack.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar\tar.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\node_modules\tar-pack\index.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\index.js'
]
}
I thought you installed block-stream first
npm init && npm i block-stream && npx create-react-app counter
or using vite
npm create vite#latest my-vue-app -- --template react
I am getting below error while trying to execute below command
npm-check-updates
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '../../package.json'
Require stack:
C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js:11:40)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js'
]
}
I see the location C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js exist. Can you help me solving this error?
I found the workaround in location https://github.com/raineorshine/npm-check-updates/issues/990
I changed "../../package.json" to "../../../package.json" in /home/ledsun/.local/share/nvm/v17.0.1/lib/node_modules/npm-check-updates/build/src/bin/cli.js:11, then the ncu runs expected.
I am new in Angular and NodeJS UTs. I have a function in test file and I have exported that function to use it in another file but once I call it from another file then I am receiving an error of describe block. Here is my code:
abc.controller.ts
export function mockGetAppByName(exists: boolean, error?: boolean) {
// some execution
}
mock.app.ts
import { mockGetAppByName} from '../../test/api/abc/abc.controller.test';
//Called function below in some other function
mockGetAppByName(true);
When I run command npm start It throws below error. If I does not export it then it works fine...When I export and import this function in another file then also I am not receiving any error...BUT...once I call that function in my code then it throws an error. It does not allow my server to start and it keep throwing error.
ERROR
C:\Ambuj Khanna\Project\STA_Console\STAConsole\server\tmp\test\api\action\action.controller.test.js:194
describe('ActionController', () => {
^
ReferenceError: describe is not defined
at Object. (C:\Ambuj
Khanna\Project\project\server\tmp\test\api\action\abc.controller.test.js:194:1)
←[90m at Module._compile (internal/modules/cjs/loader.js:955:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:811:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:723:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:848:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:74:18)←[39m
at Object. (C:\Ambuj
Khanna\Project\project\server\tmp\src\mock\mock.application.js:10:34)
←[90m at Module._compile (internal/modules/cjs/loader.js:955:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:811:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:723:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:848:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:74:18)←[39m
at Object. (C:\Ambuj
Khanna\Project\STA_Console\STAConsole\server\tmp\src\mock\index.js:5:28)
←[90m at Module._compile (internal/modules/cjs/loader.js:955:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:811:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:723:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:848:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:74:18)←[39m
at Object. (C:\Ambuj Khanna\Project\STA_Console\STAConsole\server\tmp\src\app.js:7:14)
Tried to run nodejs application.If i run node server.js i am getting module not found error.All files path is correct but i am getting module not found error.How to resolve this issue?
I have shared the errors below with folder structure:
Folder structure:
test = Main folder
node_modules
src
-controllers =folder
-dataaccess =folder
-routes =folder
-service =folder
-server.js
.angulardoc.json
package.json
package-lock.json
tsconfig.json
tslint.json
Error:
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module './dataaccess/middlewares/base/MiddlewaresBase'
Require stack:
- C:\xampp\htdocs\test\src\server.js
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966
:17)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:859:27)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:1028:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:72:18)←[39m
at Object.<anonymous> (C:\xampp\htdocs\test\src\server.js
:4:19)
←[90m at Module._compile (internal/modules/cjs/loader.js:1139:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:1
0)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:988:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:896:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_ma
in.js:71:12)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [ ←[32m'C:\\xampp\\htdocs\\test\\serve
r.js'←[39m ]
}