npm version Throwing Up An Error - macos

When I run npm version it's throwing up some errors. Here's the entire npm-debug.log file:
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'version' ]
2 info using npm#2.1.17
3 info using node#v0.10.35
4 verbose node symlink /usr/local/bin/node
5 verbose config Skipping project config: /Users/realph/.npmrc. (matches userconfig)
6 error version Bad package.json data undefined
7 verbose type unexpected_token
8 verbose stack SyntaxError: Unexpected token u
8 verbose stack at Object.parse (native)
8 verbose stack at /usr/local/lib/node_modules/npm/lib/version.js:36:19
8 verbose stack at evalmachine.<anonymous>:208:20
8 verbose stack at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:141:5)
8 verbose stack at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:61:22)
8 verbose stack at Object.oncomplete (evalmachine.<anonymous>:108:15)
9 verbose cwd /Users/realph
10 error Darwin 14.0.0
11 error argv "node" "/usr/local/bin/npm" "version"
12 error node v0.10.35
13 error npm v2.1.17
14 error Unexpected token u
15 error If you need help, you may report this error at:
15 error <http://github.com/npm/npm/issues>
16 verbose exit [ 1, true ]
Not sure if it's got anything to do with changing my shell to zsh.
Any help is appreciated. Thanks in advance!

There are two issues here.
One is that there's a bug in recent versions of npm where npm version will error if package.json is missing or contains invalid data. https://github.com/npm/npm/issues/7056 That should be fixed with npm#2.2.0 which will officially be latest sometime later today. You can upgrade by following the appropriate instructions here https://github.com/npm/npm/wiki/Troubleshooting#try-the-latest-stable-version-of-npm
The second problem is that your package.json file can't be parsed - please check out the error message above:
Bad package.json data undefined
7 verbose type unexpected_token
8 verbose stack SyntaxError: Unexpected token u
You should inspect your package.json file to see if it is valid JSON http://www.json.org/ (which is a strict subset of javascript, identifier names must be double-quoted, etc.). You can run it through a validator at http://jsonlint.com/

Related

When using "npm run watch" the webpack get compiled with 2 erros and 6 warnings

I'm trying to use Laravel CMS for my portfolio when using the exact same repo on my mac I get no errors or warnings, but when I try using it on my Windows PC I get 6 warning and 2 errors. I'm a beginner level developer, so I don't really know how to read those warnings/errors.
Edit 1:
I forgot to mention that the path i used at first was public/images/<image.png> and the same error occured.
Aplication version's:
Php: 8.1.5
Laravel: 9.11.0
npm: 8.5.5
Here is the error snippet:
npm run watch
> watch
> mix watch
Error: Can't resolve '../../storage/app/resources/images/achtergrond.png' in 'C:\portfolio\resources\css'
at finishWithoutResolve (C:\node_modules\enhanced-resolve\lib\Resolver.js:309:18)
at C:\node_modules\enhanced-resolve\lib\Resolver.js:386:15
at C:\node_modules\enhanced-resolve\lib\Resolver.js:435:5
at eval (eval at create (C:\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:16:1
)
at C:\node_modules\enhanced-resolve\lib\Resolver.js:435:5
at eval (eval at create (C:\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:27:1
)
at C:\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:87:43
at C:\node_modules\enhanced-resolve\lib\Resolver.js:435:5
at eval (eval at create (C:\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1
)
at C:\node_modules\enhanced-resolve\lib\Resolver.js:435:5
at processResult (C:\node_modules\webpack\lib\NormalModule.js:758:19)
at C:\node_modules\webpack\lib\NormalModule.js:860:5
at C:\node_modules\loader-runner\lib\LoaderRunner.js:400:11
at C:\node_modules\loader-runner\lib\LoaderRunner.js:252:18
at context.callback (C:\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
at Object.loader (C:\node_modules\css-loader\dist\index.js:155:5)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors and 6 warnings
If you need any more information just send me a message.
Thanks in advance!

How to debug #graphql-codegen/cli

Having difficult understanding where these errors are coming from. Adding --verbose and --debug to the command do nothing. I just want to know specifically what is causing the schema to fail to load. No matter what url I provide, it always fails. This wasn't happening before.
Is there any way to troubleshoot this I'm not seeing?
(node:11248) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
[STARTED] Parse Configuration
[SUCCESS] Parse Configuration
[STARTED] Generate outputs
[STARTED] Generate src/generated/graphql.tsx
[STARTED] Load GraphQL schemas
[FAILED] Failed to load schema
[SUCCESS] Generate outputs
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I think it should be fixed if you upgrade your #graphql-codegen/cli.
Check documentation:
https://the-guild.dev/graphql/codegen/docs/config-reference/codegen-config#debug-mode
Check issue:
https://github.com/dotansimha/graphql-code-generator/issues/925#issuecomment-468618967
$ graphql-codegen --debug --config codegen.yml
✔ Parse Configuration
⚠ Generate outputs
❯ Generate to src/types/api/index.ts
✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ GraphQL Document Validation failed with 23 errors;
Error 0: Cannot query field "..." on type "..."

Unable to compile assets (Laravel Mix)

I'm unable to run npm run dev command, so i could compile my assets via Laravel Mix.
Log of the commmand:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/Cellar/node/12.9.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'dev'
1 verbose cli ]
2 info using npm#6.12.0
3 info using node#v12.9.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle #~predev: #
6 info lifecycle #~dev: #
7 verbose lifecycle #~dev: unsafe-perm in lifecycle true
8 verbose lifecycle #~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/mac/Desktop/projects/project/node_modules/$
9 verbose lifecycle #~dev: CWD: /Users/mac/Desktop/projects/project
10 silly lifecycle #~dev: Args: [ '-c', 'npm run development' ]
11 silly lifecycle #~dev: Returned: code: 1 signal: null
12 info lifecycle #~dev: Failed to exec dev script
13 verbose stack Error: # dev: `npm run development`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:209:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:209:13)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid #
15 verbose cwd /Users/max/Desktop/projects/project
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/Cellar/node/12.9.0/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v12.9.0
19 verbose npm v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error # dev: `npm run development`
22 error Exit status 1
23 error Failed at the # dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Any help with understanding this log/issue would be appreciated.
Manually removing the node and npm directories (https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/), then installing a fresh node and npm version solved the issue.

Errors with installing gulp

I am trying to install Gulp and gulp-util
This is what i am getting
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\nodejs\\node.exe',
1 verbose cli 'C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'gulp-util' ]
2 info using npm#2.15.9
3 info using node#v4.6.0
4 verbose install initial load of C:\Users\icer\Desktop\github\coffeescript\project1\package.json
5 verbose stack Error: Invalid version: "1.0"
5 verbose stack at Object.module.exports.fixVersionField (C:\nodejs\node_modules\npm\node_modules\normalize-package-data\lib\fixer.js:191:13)
5 verbose stack at C:\nodejs\node_modules\npm\node_modules\normalize-package-data\lib\normalize.js:32:38
5 verbose stack at Array.forEach (native)
5 verbose stack at normalize (C:\nodejs\node_modules\npm\node_modules\normalize-package-data\lib\normalize.js:31:15)
5 verbose stack at final (C:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:349:5)
5 verbose stack at then (C:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:124:5)
5 verbose stack at ReadFileContext.<anonymous> (C:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:295:20)
5 verbose stack at ReadFileContext.callback (C:\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
5 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:303:13)
6 verbose cwd C:\Users\icer\Desktop\github\coffeescript\project1
7 error Windows_NT 10.0.14393
8 error argv "C:\\nodejs\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "gulp-util"
9 error node v4.6.0
10 error npm v2.15.9
11 error Invalid version: "1.0"
12 error If you need help, you may report this error at:
12 error <https://github.com/npm/npm/issues>
13 verbose exit [ 1, true ]

Cannot install socket.io on windows Error: connect EACCESS

I am new to what I'm doing now (Node.js,socket.io).
I've already installed Node.js and now I'm trying to install socket.io but I am having this EACCESS error. Thank you for the help!
I'm using Windows 7 x64
I ran cmd with privileges.
and then
npm install socket.io
Here is the log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'socket.io' ]
2 info using npm#1.3.14
3 info using node#v0.10.22
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose cache add [ 'socket.io', null ]
6 verbose cache add name=undefined spec="socket.io" args=["socket.io",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url slashes: null,
7 verbose parsed url auth: null,
7 verbose parsed url host: null,
7 verbose parsed url port: null,
7 verbose parsed url hostname: null,
7 verbose parsed url hash: null,
7 verbose parsed url search: null,
7 verbose parsed url query: null,
7 verbose parsed url pathname: 'socket.io',
7 verbose parsed url path: 'socket.io',
7 verbose parsed url href: 'socket.io' }
8 silly lockFile 71475bfd-socket-io socket.io
9 verbose lock socket.io C:\Users\Bobby\AppData\Roaming\npm-cache\71475bfd-socket- io.lock
10 silly lockFile 71475bfd-socket-io socket.io
11 silly lockFile 71475bfd-socket-io socket.io
12 verbose addNamed [ 'socket.io', '' ]
13 verbose addNamed [ null, '*' ]
14 silly lockFile c03de861-socket-io socket.io#
15 verbose lock socket.io# C:\Users\Bobby\AppData\Roaming\npm-cache\c03de861-socket- io.lock
16 silly addNameRange { name: 'socket.io', range: '*', hasData: false }
17 verbose url raw socket.io
18 verbose url resolving [ 'https://registry.npmjs.org/', './socket.io' ]
19 verbose url resolved https://registry.npmjs.org/socket.io
20 info trying registry request attempt 1 at 09:33:49
21 http GET https://registry.npmjs.org/socket.io
22 info retry will retry, error on last attempt: Error: connect EACCES
23 info trying registry request attempt 2 at 09:34:00
24 http GET https://registry.npmjs.org/socket.io
25 info retry will retry, error on last attempt: Error: connect EACCES
26 info trying registry request attempt 3 at 09:35:00
27 http GET https://registry.npmjs.org/socket.io
28 silly lockFile c03de861-socket-io socket.io#
29 silly lockFile c03de861-socket-io socket.io#
30 error Error: connect EACCES
30 error at errnoException (net.js:901:11)
30 error at Object.afterConnect [as oncomplete] (net.js:892:19)
30 error { [Error: connect EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'connect' }
31 error Please try running this command again as root/Administrator.
32 error System Windows_NT 6.1.7601
33 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "socket.io"
34 error cwd C:\node
35 error node -v v0.10.22
36 error npm -v 1.3.14
37 error syscall connect
38 error code EACCES
39 error errno EACCES
40 error stack Error: connect EACCES
40 error stack at errnoException (net.js:901:11)
40 error stack at Object.afterConnect [as oncomplete] (net.js:892:19)
41 verbose exit [ 1, true ]
EACCES means socket.io can't access a port. It might be because you don't have the privileges or the port is already used by another application. You should run this command as an administrator and/or close any process using the port socket.io is trying to access to.
I think it's:
runas /noprofile /root:Administrator npm install socket.io

Resources