Error on any command npm. Error on any command npm - npm

TypeError: invalid options argument at optsArg (/node_modules/mkdirp/lib/opts-arg.js:13:11) at mkdirp (/node_modules/mkdirp/index.js:11:10) at inferOwner.then.owner (/usr/share/npm/node_modules/gentle-fs/lib/mkdir.js:14:5) Error: npm.load() required at Object.get (/usr/share/npm/lib/npm.js:59:13) at process.errorHandler (/usr/share/npm/lib/utils/error-handler.js:205:32) at process.emit (events.js:198:13) at emitPromiseRejectionWarnings (internal/process/promises.js:140:18) at process._tickCallback (internal/process/next_tick.js:69:34) /usr/share/npm/lib/npm.js:59 throw new Error(npm.load() required) ^ Error: npm.load() required at Object.get (/usr/share/npm/lib/npm.js:59:13) at process.errorHandler (/usr/share/npm/lib/utils/error-handler.js:205:32) at process.emit (events.js:198:13) at process._fatalException (internal/bootstrap/node.js:497:27)
What's going on here? I do not understand anything
clean ubuntu focal.

Deleted /node_modules and installed npm via nvm. Now it works.

Related

turtle-cli: Error: 'expo-module-prepare' does not exist

Trying to build a dev version of an APK (Android) but I keep getting the following error.
14572 timing reify:rollback:createSparse Completed in 5948ms
14573 timing reify:rollback:retireShallow Completed in 14ms
14574 timing command:install Completed in 278406ms
14575 verbose stack Error: command failed
14575 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/#npmcli/promise-spawn/lib/index.js:63:27)
14575 verbose stack at ChildProcess.emit (node:events:527:28)
14575 verbose stack at maybeClose (node:internal/child_process:1092:16)
14575 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
14576 verbose pkgid #expo/html-elements#0.0.2
14577 verbose cwd /Users/faisaliqbal/.turtle/workingdir/android/sdk42
14578 verbose Darwin 21.3.0
14579 verbose node v16.15.1
14580 verbose npm v8.11.0
14581 error code 1
14582 error path /Users/faisaliqbal/.turtle/workingdir/android/sdk42/packages/html-elements
14583 error command failed
14584 error command sh -c expo-module prepare
14585 error /Users/faisaliqbal/.turtle/workingdir/android/sdk42/node_modules/commander/index.js:837
14585 error throw new Error(executableMissing);
14585 error ^
14585 error
14585 error Error: 'expo-module-prepare' does not exist
14585 error - if 'prepare' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
14585 error - if the default executable name is not suitable, use the executableFile option to supply a custom name
14585 error at ChildProcess.<anonymous> (/Users/faisaliqbal/.turtle/workingdir/android/sdk42/node_modules/commander/index.js:837:15)
14585 error at ChildProcess.emit (node:events:527:28)
14585 error at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
14585 error at onErrorNT (node:internal/child_process:478:16)
14585 error at processTicksAndRejections (node:internal/process/task_queues:83:21)
14586 verbose exit 1
14587 timing npm Completed in 278532ms
14588 verbose unfinished npm timer reify 1656882423113
Here are the versions of the app I am using.
Note: This project is working and compiling fine on another machine.
OS - darwin 12.2.1 (Monterey)
turtle - 0.27.4
Java (2) Versions:
java 18.0.1.1 2022-04-22
openjdk 11.0.15 2022-04-19
expo - 5.4.12
nodejs - v16.15.1
npm - 8.11.0
setup:android is all good
setup:ios is all good
IPA (IOS Binary) compiles without any issue.
Command to start the build:
turtle build:android \
--keystore-path ./keystore/keystore_android.jks \
--keystore-alias "store (redacted)" \
--allow-non-https-public-url \
--gradle-args "--warning-mode all" \
--public-url expo_url (redacted) \
-t apk
What might be the causing this?
Downgrading NodeJS version from 16 to 14 helped.
I originally installed NodeJS using official installer and after removing the installed version I reinstalled node using brew:
brew install node#14
(everything else I specified in my question was left untouched.

React Native Expo set up on macOS

After downloading watchman through brew and an expo blank template for my project I have attempted to run a yarn start within the terminal however, I get back the following error:
2022-06-21T09:09:00,229: [] while computing sockname: failed to create /opt/local/var/run/watchman/theflood-state: No such file or directory
Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2022-06-21T09:09:00,229: [] while computing sockname: failed to create /opt/local/var/run/watchman/theflood-state: No such file or directory
/Applications/Telsa-project/TelsaClone/node_modules/metro-hermes-compiler/src/emhermesc.js:77
throw ex;
^
Error: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2022-06-21T09:09:00,229: [] while computing sockname: failed to create /opt/local/var/run/watchman/theflood-state: No such file or directory
at ChildProcess.<anonymous> (/Applications/Telsa-project/TelsaClone/node_modules/fb-watchman/index.js:198:18)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Socket.<anonymous> (node:internal/child_process:451:11)
at Socket.emit (node:events:527:28)
at Pipe.<anonymous> (node:net:709:12)
Emitted 'error' event on Client instance at:
at spawnError (/Applications/Telsa-project/TelsaClone/node_modules/fb-watchman/index.js:170:10)
at ChildProcess. (/Applications/Telsa-project/TelsaClone/node_modules/fb-watchman/index.js:198:7)
at ChildProcess.emit (node:events:527:28)
[... lines matching original stack trace ...]
at Pipe. (node:net:709:12)
error Command failed with exit code 7.
I've tried to reinstall watchman but that doesn't seem to make a difference.
Does anyone know how I might go about fixing this error?

Unable to run NPM in MAC Terminal

Unable to run npm in mac, tried un-installing re-installing it. (Removed the NPM properly and re-installed it). But every time I am getting below error.
Error: EEXIST: file already exists, mkdir '/usr/local/bin/npm'
TypeError: Cannot read property 'loaded' of undefined
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98:27)
at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:77:20
at cb (/usr/local/lib/node_modules/npm/lib/npm.js:225:22)
at /usr/local/lib/node_modules/npm/lib/npm.js:263:24
at /usr/local/lib/node_modules/npm/lib/config/core.js:83:7
at Array.forEach (<anonymous>)
at /usr/local/lib/node_modules/npm/lib/config/core.js:82:13
at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:173:20)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
TypeError: Cannot read property 'loaded' of undefined
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98:27)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
at process.emit (events.js:196:13)
at process._fatalException (internal/process/execution.js:146:25)
When I type NPM, it should run, instead I am getting above error.
It appears to be related to user permissions. See this post: npm error on every command: EEXIST: file already exists, mkdir 'c:\users\user\appdata\Roaming\npm'. Are you running the npm command as root?

Why is TestCafe crashing on launch testing Electron app with simple command-line?

I am attempting to run a test on our Electron app using TestCafe. I am getting an error mentioning a "-m" command, however that is not used in my script or command line.
I have everything set up as described here:
https://github.com/DevExpress/testcafe-browser-provider-electron#testing-an-executable-electron-application
C:\packages>testcafe -d "electron:C:\Program Files\OurApp\"
"C:\Temp\test.js" -hostname localhost
Using locally installed version
of TestCafe. ERROR Tested app failed with an error:
Error: Command failed: -m '-m' is not recognized as an internal or
external command, operable program or batch file.
at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Socket.stream.socket.on (internal/child_process.js:346:11)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at Pipe._handle.close [as _onclose] (net.js:557:12)
Type "testcafe -h" for help.
The script for test.js is below:
import { Selector } from 'testcafe';
fixture `Electron test`
.page('./index.html');
test('smoke 1', async t => {
await t
.debug()
.click(Selector().withText('Create a new configuration'));
});
What could be the cause?
The cause is in an incorrect -hostname argument. It should be --hostname. I'm not sure why some -m error appears but tests work after I fix incorrect argument syntax.

Trow error when trying to make new vue-cli webpack project

I keep getting a throw error with permission denied when trying to make a new vue-cli webpack build. It worked last night, but now all of a sudden I get these errors. Anyone know how to fix this?
/usr/local/lib/node_modules/vue-cli/node_modules/rimraf/rimraf.js:312
throw er
^
Error: EACCES: permission denied, unlink
I was also getting this kind of error:
downloading template
/usr/local/lib/node_modules/#vue/cli-init/node_modules/rimraf/rimraf.js:313
throw er
^
Error: EACCES: permission denied, unlink '/home/apoorv/.vue-templates/webpack/.gitignore'
at Object.unlinkSync (fs.js:956:3)
at rimrafSync (/usr/local/lib/node_modules/#vue/cli-init/node_modules/rimraf/rimraf.js:306:17)
at /usr/local/lib/node_modules/#vue/cli-init/node_modules/rimraf/rimraf.js:342:5
at Array.forEach (<anonymous>)
at rmkidsSync (/usr/local/lib/node_modules/#vue/cli-init/node_modules/rimraf/rimraf.js:341:26)
at rmdirSync (/usr/local/lib/node_modules/#vue/cli-init/node_modules/rimraf/rimraf.js:334:7)
at rimrafSync (/usr/local/lib/node_modules/#vue/cli-init/node_modules/rimraf/rimraf.js:304:9)
at downloadAndGenerate (/usr/local/lib/node_modules/#vue/cli-init/node_modules/vue-cli/bin/vue-init:149:20)
at checkVersion (/usr/local/lib/node_modules/#vue/cli-init/node_modules/vue-cli/bin/vue-init:130:11)
at Request.request [as _callback] (/usr/local/lib/node_modules/#vue/cli-init/node_modules/vue-cli/lib/check-version.js:29:5)
at Request.self.callback (/usr/local/lib/node_modules/#vue/cli-init/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request.<anonymous> (/usr/local/lib/node_modules/#vue/cli-init/node_modules/request/request.js:1161:10)
at Request.emit (events.js:198:13)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/#vue/cli-init/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:286:20)
It seemed like I didn't have appropriate permissions to
/home/apoorv/.vue-templates/webpack/.gitignore
Following #Nathan Wailes' answer, I just changed the permissions and resolved my issue using:
chmod -R 777 /home/apoorv/.vue-templates/*
It looks like you're running this command on Linux; try using chown to give yourself permission to access all of those directories / files.
See also: GitHub - Bower - EACCES: permission denied