npm or yarn test fails with "npm ERR! enoent spawn bash ENOENT" - npm

I am trying to follow a tutorial on how to fork Compound (https://medium.com/compound-finance/a-walkthrough-of-contributing-to-the-compound-protocol-9450cbe2133a). I want to add a new token. But in order to do that, I need to first be able to get the app to pass all tests.
The problem is that I can't get the tests to run in the first place. According to the tutorial, I simply need to type yarn test to run the tests. However, when I try to do this, I get error messages that seem to imply that it cannot find the path to the test file. For example:
'.\script\test' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command." >
or
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\tombl\Documents\Code\compound-protocol
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent>
After investigating some, I discovered that it is trying to run a script in package.json called "test".
The script looks like this: "test": "./script/test",
At first, I got a response saying that "." is not a recognized command. I then tried to put the entire pathname in it so that it wouldn't have a period in it. So I edited package.json to say "test": "C:/Users/tombl/Documents/Code/compound-protocol/script/test",
That didn't work. Next, I tried to edit the environment variables in Windows so that CMD would recognize the folder (I'm using a terminal from within Visual Studio Code). That didn't work either.
After reading some other stack exchange answers, I followed the advice here (npm - The system cannot find the path specified) and typed npm config set script-shell bash. This also didn't work.
In addition, I tried editing package.json so that there is a second set of quotes in the path, like this: "test": "'C:/Users/tombl/Documents/Code/compound-protocol/script/test'", But it still didn't work.
Oh, and I tried using npm test instead of yarn test.
At this point, I have no idea what to try next.
I can see very clearly in file manager that the "test" file is there and that the path I've stated is correct. I can even open up the test file and see the code inside of it. But I can't get the terminal to run it. It just says that it isn't there.
One clue I do have is that it stops at the folder "compound-protocol". So it either doesn't recognize the folder compound-protocol at all or it doesn't recognize that the script folder is inside of it.
I've wondered if maybe the hyphen in "compound-protocol" is causing the problem, but the only advice I've gotten on how to fix that is to put the whole path in quotes, which I've already tried.
I've even tried navigating to the script folder within the terminal and running the test from there. While it does let me navigate into the script folder, trying to run the test produces a > Program 'test' failed to run: No application is associated with the specified file for this operationAt line:1 char:1. > error message.
Does anyone know how I might go about fixing this?

have you tried to use yarn install first? Also you need to use Node.js version 12 with that repository. NVM is a great tool to quickly switch between versions of Node on the command line. https://nvm.sh

Related

How do I install react and react-redux onto my project?

Good afternoon,
I am trying to install react and react-redux onto my project, but I keep getting errors that I don't understand.
$ npx create-react-app learn-redux
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Phelps\AppData\Roaming\npm-cache\_npx\13464" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Taylor Phelps\AppData\Roaming\npm-cache\_logs\2020-02-08T20_44_17_568Z-debug.log
Install for [ 'create-react-app#latest' ] failed with code 1
Could not install from "Phelps\AppData\Roaming\npm-cache\_npx\13464" as it does not contain a package.json file.
I am reading the error, but the problem is...that folder does not exist on my computer and I've checked in the terminal for npm and npx and both are installed on my computer. Does anyone have any ideas on why this may be happening and how to fix it?
Thank you.
According to this Github issue npx has trouble running on Windows if the user has a space in their name and from the error message I'd guess that is the case here. One of the suggested fixes is to set your npm-cache path to a folder without a space in it:
npm config set cache C:\tmp\nodejs\npm-cache --global
Then try running your command again.
Install the project in another directory except C partition :
npx create-react-app learnredux
Then :
npm i react-redux --save
This should work.
The problem is the npm cache by the path of the error. Try running:
npm cache verify
Verify the contents of the cache folder, garbage collecting any
unneeded data, and verifying the integrity of the cache index and all
cached data.
(from https://docs.npmjs.com/cli-commands/cache.html)

Errors when installing discord.js

I've been having some trouble with installing discord.js to my node_modules using windows powershell. I have checked multiple times and know I have the correct version of node, but every time I run npm install discord.js, it will go for awhile then gives me a bunch of errors like so
PS C:\Users\kevin\Desktop\Bot> npm install discord.js
(I removed the warnings and just left the errors that cause the installation not to work)
npm ERR! path C:\Users\kevin\Desktop\Bot\node_modules\async-limiter
npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall rename npm
ERR! enoent ENOENT: no such file or directory, rename
'C:\Users\kevin\Desktop\Bot\node_modules\async-limiter' ->
'C:\Users\kevin\Desktop\Bot\node_modules.async-limiter.DELETE' npm
ERR! enoent This is related to npm not being able to find a file. npm
ERR! enoent
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\kevin\AppData\Roaming\npm-cache_logs\2018-03-26T14_38_26_242Z-debug.log
(sorry if this didn't help)
I don't know what is wrong and can't seem to find anything online to help so hoping this might work, Thanks a lot.
(I also have node version 8.10.0)
Found this: https://github.com/npm/npm/issues/17444. There seem to be multiple workarounds there:
After npm got to the point that it was unusable, just before
reinstalling it, I had an idea: I opened task manager (I'm using
Windows) and found a bunch of instances of nodejs running. I was able
to shut them all down. Then when I ran npm install again, which at
this time was failing 100% of the time, and found that it was able to
execute without any problem.
Here is another one:
Workaround: Our standard workaround for this and all other NPM 5.x
problems is:
Delete package-lock.json and run NPM again.
Also a few users said it was caused by Malwarebytes Ransomware Protection, try disabling it and check if it fixes.
I had the same issue, what I had to do was open powershell on my desktop (not in a folder) and install npm to system32 (default location) then move the files to the folder I wanted them in. To get there, Navigate to the Windows System32 folder. Click the "Start" button and select "Computer." In the left-side window pane, locate and click on "Computer." Locate and click on the "(C:)" drive, locate and click on the "Windows" folder, locate and click on the "System32" folder. There will be a node_modules folder. Feel free to move or copy it, I recommend copying as its annoying to redo the instillation every time you want to add a file to it. (as in nmp i discord.js or npm i sql) Hope this works for you! :3 (feel free to message me if it didnt help for a more detailed answer, or walk through lol VampyMaria#4980 im also still learning node.js and discord.js so I cant really help with coding)

npm run cannot run an script found in node_modules/.bin/___

I installed sequelize-cli:
npm install sequelize-cli --save
I have only installed it locally, not globally. My local project is at C:/git/craft
I try to execute it by typing sequelize-cli, but this doesn't work; I forget I must type node_modules/.bin/sequelize-cli
I want to use npm run sequelize-cli, expecting this will be a shortcut. The npm-run-script documentation says:
In addition to the shell's pre-existing PATH, npm run adds
node_modules/.bin to the PATH provided to scripts. Any binaries
provided by locally-installed dependencies can be used without the
node_modules/.bin prefix
And yet, when I try to run the script:
"scripts": {
"sequelize-cli":"sequelize-cli"
},
The result fails:
NND#usrem-nnd MINGW64 /c/git/craft (master)
$ npm run sequelize-cli -- --help
> craft#0.0.0 sequelize-cli C:\git\craft
> sequelize-cli "--help"
'sequelize-cli' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "sequelize-cli" "--" "--help"
I couldn't find similar questions/issues online (specifically re: node_modules/.bin/____)
Some Github issues mention that yarn should work, (but also say that npm should work as I expect!.) As a workaround I will just install sequelize-cli globally. I can install sequelize-cli globally, but then running sequelize-cli still produces "command not found". This led me to see my silly mistake...
I had the same question as you. You may have the same problem
Finally, I found it's caused by my project folder has invalid letter.
Change your project folder name and try again.
Ensure you are referencing a script that exists! I wasn't! In fact, npm run was just revealing the obvious problem: the script sequelize-cli doesnt exist anywhere on the computer!
... The script is called sequelize, even though it comes from a project called sequelize-cli. package.json "scripts" value will determine which scripts can be run; the correct package.json should map the script "sequelize" to the nodejs command sequelize:
"scripts": {
"start": "node ./bin/www",
"sequelize":"sequelize"
},
npm run sequelize now works...
My mistake... this answer can be deleted if it's unhelpful.

how to solve:npm run build/dev: missing script?

I'm trying to run node, but for some reason the local npm install of node isn't working.
The package is there:
$ npm run dev npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node/5.6.0/bin/node" "/usr/local/bin/npm" "run" "jshint"
npm ERR! node v5.6.0
npm ERR! npm v3.6.0
npm ERR! missing script: dev
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/me/workspace/testapp/npm-debug.log
I can work with npm install, but run npm dev is not correct.
You saw that error because there was probably not a script named dev in the "scripts" section of your package.json
npm install and npm run dev are two completely different ideas
npm install will run through dependencies section of the package.json and fetch/install the modules in that list
npm run dev will check the scripts section of the package.json and try to find a script titled "dev" and if there is no script named "dev" it will error out as you experienced (Dev is absolutely not a special word by the way, if you ever need to use the scripts section in a future project you can name the scripts anything you want.)
As an example, make a new folder and copy the following into a file named package.json inside of it
{
"name": "testapp",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "echo This is the DEV script",
"abc": "echo This is the abc script",
"xyz": "echo This is the xyz script",
"start":"echo This is the special start script"
}
}
From your terminal, cd into the directory you made containing that sample package.json and try the following commands and see what happens:
npm run dev you should see on your screen "This is the dev script"
npm run abc you see on your scree "This is the abc script"
npm run xyz you should see on your screen "This is the xyz script"
npm run linkxu1989 you should see on your screen a similar error to what you saw above since there's no script named "linkxu1989" in the scripts part of the package.json
npm start you should see on your screen "This is the special start script" (Note that start IS a special name. You can run with just npm start or with npm run start like all the others`
Bottom line: Check the "scripts" section of package.json and to run any of them just enter npm run SCRIPT_NAME
Hope that helps and good luck w/ NPM!
See here for more details
https://docs.npmjs.com/getting-started/using-a-package.json
http://browsenpm.org/package.json (don't worry about understanding everything in it, all you should think about at this point is what's in "dependencies"
http://jsonlint.com/ (If you ever manually edit a package.json, run it through this checker to help catch any formatting mistakes. The package.json is a "json" file so it needs to be in a PERFECT format which means no trailing commas, double quotes only, etc etc)
http://www.w3schools.com/js/js_json_syntax.asp
It means in your “package.json” (in the folder in which you run “npm run build”), there’s NO “build” script. A quick check: run “npm run lalala” in your terminal/command prompt. It will show “missing script: lalala”.
So if it’s your package, add the “build” script. Just go to the package.json in your code editor and add the key value entry as JSON.
If it’s a module/package you downloaded from npmjs.org, then refer to the documentation to see what command they support.
Note: “npm build” is a completely different command from “npm run build”. All “scripts” commands except start and test need to be run with “run”.

How to see logs from npm installation?

I am unable to install ionic through npm. Are there any logs that I can check to see what's wrong and if yes, where are they located?
What I see is the waiting stick dancing forever. I've waited for an hour or so but nothing changes.
Append the --loglevel verbose argument to the command you want to run and all logs will be shown on STDERR and saved to npm-debug.log file in the current working directory.
Example usage: npm install ionic --loglevel verbose.
Running the npm commands like this, shows the logs in realtime and saves the logs to the directory its running within.
For permanent solution, just edit the global npm configuration. To do this, run npm config edit command and add loglevel=verbose. Now every npm command will show detailed logs