I was started to read "Developing an AngularJS Edge", and I wanted to set up the various frameworks in use.
The book uses nodejs and karma, along with several other frameworks.
I'm on Win7x32.
I just upgraded my nodejs to the latest, v0.10.18 .
I installed the Karma package with "npm install -g karma". This appeared to complete successfully.
I then ran "karma init", which did this:
% karma init
>
readline.js:507
this.line = this.line.slice(this.cursor);
^
TypeError: Cannot call method 'slice' of undefined
at Interface._deleteLineLeft (readline.js:507:25)
at suggestNextOption (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:167:9)
at nextQuestion (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:235:12)
at process (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:250:10)
at Object.exports.init (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:352:6)
at Object.<anonymous> (C:\Users\David\AppData\Roaming\npm\node_modules\karma\bin\karma:25:37)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Note that this error is virtually identical to the stack trace reported by this person a month ago, but that report has received no response.
Probably you're using the Git Bash terminal, MinTTY, which doesn't have full support for TTY.
You have 4 options to fix the problem:
Use CMD terminal with the Windows shell (the default Windows console)
Use CMD terminal with the Bash shell (execute "C:\Program Files\Git\bin\bash.exe" --login -i in cmd terminal)
Use Powershell (an alternative terminal typically installed by default in Windows environments)
Use an alternative terminal (or develop a new one :stuck_out_tongue_winking_eye: )
If you just need execute isolated interactive commands like karma init, I recommend option 1 for it and then come back to Git Bash. However I would give a try to Powershell.
The reason for the error with running npm in Cygwin seems to be a known issue with npm. You can use the work around mentioned here,
https://stackoverflow.com/a/22436199/2390020
Faced the same issue.try this
node node_modules/karma/bin/karma init
I got the same error with MINGW64.
Runs properly on default command prompt.
One other likely relevant point that I failed to mention is that I was running these commands from a Cygwin rxvt window.
I just tried completely uninstalling nodejs and reinstalling it.
When I brought up the rxvt window again and ran "npm install -g karma", it failed with the following:
/c/Program Files/nodejs/npm: line 2: $'\r': command not found
/c/Program Files/nodejs/npm: line 4: $'\r': command not found
/c/Program Files/nodejs/npm: line 5: syntax error near unexpected token `$'in\r''
'c/Program Files/nodejs/npm: line 5: `case `uname` in
That led me to search for that error on the web, and I found this thread, which implies that it simply doesn't support Cygwin (unfortunate, but not a huge problem).
When I then brought up a plain, ugly, unfriendly "cmd" window, both the karma installation and "karma init" completed successfully (or at least it gave me the first question in the "init" process).
In my case, the problem was that I was using the git bash terminal in windows. When I ran the command in a cmd window it worked fine.
Run the command in github shell command window. Worked for me.
If you open up the karma file it's just a node script, so an alternative way of executing it would be:
node karma init
This worked for me in the MINGW64/git bash shell
Related
The guide I am using https://www.youtube.com/watch?v=9cdsQWRDNM4 time marker (7:27) is where it goes to all wrong.
This is where I am having issue with my Streamr node install. Its a very basic install. The issue I am having is I'm very new to putty and this section isn't the same as the install is supose to be -- /root/.streamr/config/default.json but when I change it it becomes another error. The following sentence is what I am generating which becomes an error also which prevents myself from starting my node up (on my vps) Select a path to store the generated config in /home/streamr/.streamr/config/default.json
Either way I am getting an error.
**This is a screen shot of what I am dealing with !!! Any help with putty and setting up VPS would be great. **
can provide actual screenshot if needed!!
: Welcome to the Streamr Network
: Your node's generated name is Leopard Wrist Pond.
: View your node in the Network Explorer:
:
: You can start the broker now with
: streamr-broker /home/streamr/.streamr/config/default.json
root#ubuntu-s-1vcpu-1gb-tor1-01:~# docker run -it -p 7170:7170 -p 7171:7171 -p 1883:1883 -v $(cd ~/.streamr Docker; pwd):/root/.streamr streamr/broker-node:latest streamr/broker-node:lates **Error: Config file not found in the default location. You can run "streamr-broker-init" to generate a confi g file interactively, or specify the config file as argument: "streamr-broker path-to-config/file.json"
at readConfigAndMigrateIfNeeded (/home/streamr/network/packages/broker/dist/src/config/migration.js:155 ** :19)
at Command. (/home/streamr/network/packages/broker/dist/bin/broker.js:20:69)
at Command.listener [as _actionHandler] (/home/streamr/network/node_modules/commander/lib/command.js:48 8:17)
at /home/streamr/network/node_modules/commander/lib/command.js:1227:65
at Command._chainOrCall (/home/streamr/network/node_modules/commander/lib/command.js:1144:12)
at Command._parseCommand (/home/streamr/network/node_modules/commander/lib/command.js:1227:27)
at Command.parse (/home/streamr/network/node_modules/commander/lib/command.js:897:10)
at Object. (/home/streamr/network/packages/broker/dist/bin/broker.js:41:6)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
npm notice
npm notice New major version of npm available! 8.19.3 -> 9.4.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.4.2
npm notice Run npm install -g npm#9.4.2 to update!
npm notice
Ive tried both ways for the file name but both end in errors. Im nt sure why its not generating a /root/.streamr/config/default.json. Its giving me this strange file name that doesn't work either streamr-broker /home/streamr/.streamr/config/default.json. This one will let me finish the set up of the docker but it will not let me start the node and generates an error as seen in the code!
I am trying to make a 'Coocking-aid'. I am using a Raspberry Pi 4B with the official 7" touchscreen and an active piezo buzzer. The 'program' should run in Chromium (the RPi's webbrowser) and I write it in HTML, CSS and Javascript. I can do some tricks in Javascript but lack a lot of knowledge there. I try to sound the buzzer with Javascript, but so far without success.
The buzzer is connected between GPIO-pin 17 and Ground (connector-pins 11 and 9). When GPIO 17 is made high (+3V) the buzzer will sound.
I have tested this 'circuit' with a small Python program, which successfully turned the buzzer on:
1. from gpiozero import Buzzer
2. buzzer = Buzzer(17)
3. buzzer.on()
To do the same with Javascript I learned that I needed to install Node.js and its module 'onoff'.
From this web-post 1 I learned how to install node.js, by typing the following commands in the terminal:
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt install -y nodejs
I checked the installation by typing: "node -v". The response was: "v15.12.0"
I also checked the version of Node's package manager by typing: "npm -v". The response was: "7.7.5"
From this web-post 2 I learned how to install "onoff" by typing the following command in the terminal:
npm install onoff
I checked the installation by typing: "node -v". The response was "v15.12.0"
In the RPi directory "/home/pi/node_modules/onoff/examples" is a file called: "blink-led.js"
which I used as an example to create (in the same directory) a file called: "test.js" with the following code:
'use strict';
const Gpio = require('../onoff').Gpio; // Gpio class
const buzzer = new Gpio(17, 'out'); // Export GPIO17 as an output
buzzer.writeSync(17); // Make GPIO-pin 17 high
In the terminaI I moved to the same directory by typing:
cd /home/pi/node_modules/onoff/examples
and then executed "test.js" file by typing:
node test.js
Unfortunately the buzzer was not activated and a comprehensive error message was shown (see under).
I get the impression that the numbers are program line numbers and I had a look here and there, but I can't figure out what is wrong.
Any help would be much appreciated!.
The error message was:
/home/pi/node_modules/bindings/bindings.js:121
throw e;
^
Error: libnode.so.64: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1151:18)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at bindings (/home/pi/node_modules/bindings/bindings.js:112:48)
at /home/pi/node_modules/epoll/epoll.js:7:31
at Object.<anonymous> (/home/pi/node_modules/epoll/epoll.js:15:3)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10) {
code: 'ERR_DLOPEN_FAILED'
}
Just started with expo and React-Native and when I run
expo init ProjectName
I am getting an error stating:
Unexpected end of JSON input while parsing near '...,"version":"7.0.0-bet'
Process exited with non-zero code: 1
Set EXPO_DEBUG=true in your env to view the stack trace.
When I add the said thing in env (using set EXPO_DEBUG=true on windows), I get the following error:
Error: Process exited with non-zero code: 1
at ChildProcess.child.on (C:\Users\mohit\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\spawn-async\build\spawnAsync.js:39:21)
at ChildProcess.emit (events.js:182:13)
at ChildProcess.cp.emit (C:\Users\mohit\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
It's something related to 'spawn-async'. I was also getting issues with 'spawn' sometime earlier while creating a node-server...but I resolved that there and then using 'exec' instead. Tried to find this on expo forums and even in react-native issues but couldn't find a solution. Can someone plz suggest something? Is it some "windows" thing only or something related to npm releases?
P.S: I also ran create-react-native-app ProjectName and again got a similar kind of error about end of JSON input!
Now I know what can be the issue, it can be just the trivial one:
Please update node an npm to the newest available version and please init you project again in different directory.
You'll need to have Node.js (version 10 or newer) installed on
your computer. Download the latest version of Node.js.
Additionally, you'll need Git to create new projects with Expo
CLI. You can download Git from here.
Make sure that you have installed these two things in your device.
Go to doc for expo installation
in my case. make sure you have yarn installed and update tour android studio packages, for it to work
I'm using windows 8.1 x64 with all updates.
I was using nodejs 8.9.1 - I took an error on command "npm -v".
So I uninstalled this version and install 8.9.3. It gave me same error on the command.
And then I uninstalled 8.9.3 and clean all paths using this answer;
https://stackoverflow.com/a/20711410/1143249
Then installed new version 9.3.0...
But still, I'm getting same error in all npm commands.
What am I missing? How can I solve this problem?
C:\Users\UserName\Desktop>npm -v
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at _errnoException (util.js:999:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
at onErrorNT (internal/child_process.js:389:16)
at process._tickCallback (internal/process/next_tick.js:152:19)
at Function.Module.runMain (module.js:703:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3
C:\Program Files\nodejs\node_modules\npm\lib\npm.js:51
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:51:13)
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at process.emit (events.js:159:13)
at process._fatalException (bootstrap_node.js:387:26)
5.5.1
events.js:136
throw er; // Unhandled 'error' event
^
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at _errnoException (util.js:999:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
at onErrorNT (internal/child_process.js:389:16)
at process._tickCallback (internal/process/next_tick.js:152:19)
at Function.Module.runMain (module.js:703:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3
Update:
Everytime I uninstalled nodejs, clean/delete folders and tried these versions;
- node-v9.3.0-x64 not working
- node-v8.9.3-x64 not working
- node-v8.9.1-x64 not working
- node-v8.9.0-x64 not working
- node-v7.10.0-x64 shows version number also a small error.
Here is the output;
C:\Users\UserName\Desktop>npm -v
5.6.0
events.js:163
throw er; // Unhandled 'error' event
^
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at exports._errnoException (util.js:1050:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3
Update:
I uninstalled Avg anti-virus protection and installed node-v6.12.3-x64.msi. Still I have problems, an example; I can't run commands like;
Last Update
Thanks for all answers ( until this date: 10.02.2018 03:30 PM GTM+3 )
( I've completed some of my jobs with vm windows until this date but now I've sad news.)
I ran out all options and I have still a lot work to do with npm packages.
So, I've formatted my machine and replace with Windows 10 Enterprise x64.
I can't try new answers now but here is golden point what I've learned;
If you have mission critical machine like ci-build (jenkins etc.) or
if you don't have more than one computer (And vm is not an option)
Just backup your drive completely at time to time because you will never know
your computer softwares (like node - npm) could give an interesting errors such as this. That's what I learned, just saying...
The workaround is to ensure that C:\Users\{user}\AppData\Roaming\npm exists and is writable with your normal user account.
see Troubleshooting
Although haven't tested Node on Windows 8, I suggest you get rid of npm installation under AppData folder altogether. You can achieve this by using a Node version manager. I recommend Nodist. You can easily switch between versions as well.
With Nodist you can run the command as such:
nodist 6.2.10
One of the things I suspect is Node runtime's limited access to required files under C:/ drive - maybe something related to Windows 8. That said, you could install nodist in any drive other than C:/. Meanwhile as mentioned by #fjoe, stick with LTS versions especially v6.x.x.
Here are a few things to consider when picking your node.js version.
Version labelled as LTS (Long Term Support) are the releases they stand behind.
You can see a full list of versions here notice the LTS column. It is also interesting to see the versions of V8 and npm that are packaged with each.
Node 9.* has no official LTS release.
Node 8.* officially entered LTS on 10-31-2017 (3 months ago).
I personally have run into problems with it.
Node 7.* never officially released as LTS.
Node 6.* has 2 years of official LTS releases and they are continuing to support it.
With the most recent release on 01-02-2018.
Given this information might I recommend you try the proven long supported version 6.*
If this works then maybe hold off on version 8.* until more things get ironed out.
Other people have commented on your question about environment variables for node or npm. This is obviously not the issue as the commands are recognized and running (but they error).
Also I would recommend you follow this full uninstall guide: How to completely remove node.js from Windows
My coding buddy had a similar error yesterday, although on Linux.
The error was in the node_modules folder, so removing that and reinstalling node solved it for him.
That would be your node_module folder in AppData\Roaming\npm.
I guess the problem can be in NPM itself.
try to update your NPM.
Try to use this great approach
By the way, it's great to know what npm version you have with your changes of node.js versions.
From the logs you provided it looks like a cache bug, because of some junk that previously exists and that is causing issues.
Open the command prompt with admin privileges and follow the below steps:
1) Clear the cache: npm cache clean --force. You can also run npm cache verify.
2) Delete node_modules folder using: rm -rf node_modules.
3) Delete any package-lock.json file.
4) Remove the .npm directory.
5) Remove following directories :
5.1) C:\Users\<username>\AppData\Roaming\npm\.
5.2) C:\Users\<username>\AppData\Roaming\npm-cache.
6) Also, Try by setting environment variables:
C:\Users\<username>\AppData\Roaming\npm;C:\Program Files\nodejs.
Type in the command line: which npm.
Maybe you did not set the system value : NODE_PATH it should point to your global module location.
7) Update to the latest npm with npm i -g npm#latest.
Hope the above trick resolve your issue.
Thanks.
I guess while installing Node.js it don't able to set it's environment path due to permission.
You Need to configure Node path manually into environment variables.
The gulp task
/* Run the npm script npm run buildLsdk using gulp */
gulp.task('sdk', function() {
if (process.cwd() != basePath) {
process.chdir('..');
// console.log(process.cwd());
}
spawn('./node_modules/.bin/lb-sdk', ['server/server.js', './client/src/app/shared/sdk', '-q'], {stdio: 'inherit'});
});
I am getting the following stack trace but i cannot debug
Error: spawn ./node_modules/.bin/lb-sdk ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
I have all the necessary files in node modules too any help is really appreciated.
More reference on the File use above - https://github.com/rahulrsingh09/loopback-Angular-Starter/blob/master/gulpfile.js
I think it's because lb-sdk.cmd is the file you're supposed to run on windows. when I changed the command to the below the error goes away. Please note the windows style directory slashes are different from linux.
gulp.task('sdk', function() {
spawn(
'.\\node_modules\\.bin\\lb-sdk.cmd',
[
'.\\server\\server.js',
'.\\client\\src\\app\\shared\\sdk',
'-q'
], {stdio: 'inherit'}
);
});
I found some more information,and I'm going to post a second answer I found (above one was accepted).
If you want to avoid changing directories in windows/linux you can use cross-spawn: https://www.npmjs.com/package/cross-spawn
win-spawn (from the chat dialog) is not maintained anymore per the github repo . If you're interested in using it make the following changes:
npm install cross-spawn
npm install spawn-sync
npm install strongloop (needs to be reinstalled per this link)
change 'google chrome' in browser-sync task to chrome.exe per this link:
run gulp
Please refer to this similar answer, this will solve your issue:
Convert the following npm script to gulp task
How to automate the build from the following configuration using gulp
And you can check the documentation of lb-sdk by typing ./node_modules/.bin/lb-sdk in your terminal.
Can you try using basePath when passing server/server.js and ./client/src/app/shared/sdk. Like for example:
spawn(
'./node_modules/.bin/lb-sdk',
[
basePath + '/server/server.js',
basePath + '/client/src/app/shared/sdk',
'-q'
], {stdio: 'inherit'}
);