I'm trying to run: "npm run test" on Node.js.
OS: Win10.
Getting error:
node_modules\.bin\wdio:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
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 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Related
I have recently started learning and attempting to use the npx mix commands but whenever I try to execute the command it returns this error:
node:internal/modules/cjs/loader:949
throw err;
^
Error: Cannot find module 'libnpx'
Require stack:
- /usr/share/npm/bin/npx-cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
at Module._load (node:internal/modules/cjs/loader:787:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/share/npm/bin/npx-cli.js:3:13)
at Module._compile (node:internal/modules/cjs/loader:1112:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:834:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/share/npm/bin/npx-cli.js' ]
}
I am not sure how to fix this problem - any help with solving this would be greatly appreciated!
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 have node.js version
C:\helloworld-webpart>node -v
v10.24.1
and when i run this command using cmd windows i got this error:-
C:\helloworld-webpart>yo #microsoft/sharepoint
C:\Users\mohan\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70
filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`, `${prefix}/*/index.cjs`, `${prefix}/*/index.mjs`]),
^
TypeError: lookups.flatMap is not a function
at Environment.resolver.lookup (C:\Users\mohan\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70:27)
at init (C:\Users\mohan\AppData\Roaming\npm\node_modules\yo\lib\cli.js:130:7)
at pre (C:\Users\mohan\AppData\Roaming\npm\node_modules\yo\lib\cli.js:89:3)
at Object.<anonymous> (C:\Users\mohan\AppData\Roaming\npm\node_modules\yo\lib\cli.js:219:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
any advice?
I think I've seen this error on my local computer when I'm missing a module, but I am trying to start my code with pm2. Is that what the error is seen here?
0|my-ba | at Object.<anonymous> (/home/user/website/index.js:4:1)
0|my-ba | at Module._compile (internal/modules/cjs/loader.js:1133:30)
0|my-ba | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
0|my-ba | at Module.load (internal/modules/cjs/loader.js:977:32)
0|my-ba | at Function.Module._load (internal/modules/cjs/loader.js:877:14)
0|my-ba | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:32:23)
0|my-ba | at Module._compile (internal/modules/cjs/loader.js:1133:30)
0|my-ba | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
0|my-ba | at Module.load (internal/modules/cjs/loader.js:977:32)
0|my-ba | at Function.Module._load (internal/modules/cjs/loader.js:877:14)
0|my-ba | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
0|my-ba | at internal/main/run_main_module.js:18:47 {
0|my-ba | code: 'MODULE_NOT_FOUND',
0|my-ba | requireStack: [ '/home/user/website/index.js' ]
0|my-ba | }
It says it doesn't know how to "start" your app, as it's not in home/user/website/index.js
You need to edit your package.json and see which is the start command and move your files accordingly (or edit, whichever is more convenient)
I am trying to write the unit test case using mocha and chai but I am getting the error:-Cannot find module './--require.js when I run the test case.
the script is:- "test": "mocha --require babel-core/register 'server/api/**/*.test.js'"
full error:-
D:\gitlab-to-azure\blik-app\node_modules\yargs\yargs.js:1163
else throw err
^
Error: Cannot find module './--require.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.getConstants (D:/gitlab-to-azure/blik-app/server/config/environment/index.js:12:16)
at Object.<anonymous> (D:/gitlab-to-azure/blik-app/server/app.js:20:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at loader (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (D:/gitlab-to-azure/blik-app/server/api/group/group.test.js:2:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at loader (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\mocha.js:334:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\mocha.js:331:14)
at Mocha.run (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\mocha.js:809:10)
at Object.exports.singleRun (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\run-helpers.js:108:16)
at exports.runMocha (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\run-helpers.js:142:13)
at Object.exports.handler.argv [as handler] (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\run.js:292:3)
at Object.runCommand (D:\gitlab-to-azure\blik-app\node_modules\yargs\lib\command.js:242:26)
at Object.parseArgs [as _parseArgs] (D:\gitlab-to-azure\blik-app\node_modules\yargs\yargs.js:1087:28)
at Object.parse (D:\gitlab-to-azure\blik-app\node_modules\yargs\yargs.js:566:25)
at Object.exports.main (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\cli.js:68:6)
at Object.<anonymous> (D:\gitlab-to-azure\blik-app\node_modules\mocha\bin\mocha:164:29)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)```
Folder Structure:-
server
api
groups
controller.js
model.js
groups.test.js
You would need to qualify for the full path for the mocha runner, you can try something like this
"test": "./node_modules/.bin/mocha --compilers js:#babel/register 'server/api/**/*.test.js'"