here is my package.json:
{
"name": "cypressautomation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "/node_modules/.bin/cypress run "
},
"author": "",
"license": "ISC",
"devDependencies": {
"cypress": "^9.2.0",
"mochawesome": "^7.0.1",
"mochawesome-merge": "^4.2.1",
"mochawesome-report-generator": "^6.0.1"
},
"dependencies": {
"cypress-iframe": "^1.0.1"
}
}
I have built some test scripts, and after I saved all files and run npm run test I get the error:
cypressautomation#1.0.0 test > /node_modules/.bin/cypress run
The system cannot find the path specified.
You might be facing issues with relative/absolute path conventions.
First let us cover the basis. From the command line at the folder where the package.json file is located, run npm install for the packages to be downloaded into the local node_modules folder.
You could change the command on package.json to:
"test": "cypress run"
this way we leave npm to figure out where cypress is located (will be in the node_modules folder and npm 'knows' about it)
then try the test command again:
npm run test
I hope you are trying to run project in correct path. if your npm run test is not working, first in command prompt try running command then add the same in package json.
I use this coomand to run project ./node_modules/.bin/cypress run
Related
I simply am trying to import web3 to my project and for whatever reason I cannot seem to resolve the issue I am facing. The relevant code is posted below:
Example.js
const Web3 = require('web3');
console.log('hi');
Package.json
{
"name": "inbox",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"author": "",
"license": "ISC",
"dependencies": {
"ganache-cli": "^6.12.2",
"mocha": "^9.1.2",
"solc": "^0.4.17",
"web3": "^1.7.2"
}
}
I'll get the preliminary questions out of the way:
Yes, I have run "npm install web3"
Yes, I have tried deleting the node_modules folder and package-lock.json file and re-running "npm install"
Yes, I have tried switching to running "npm install ethereum/web3.js"
When running "node Example.js", I get the following error:
Error: Cannot find module '/Users/username/project/node_modules/web3/lib/index.js
After looking through my node_modules folder, I found that the actual path to the index.js file of the web3 folder is: /Users/username/project/node_modules/web3/src/index.js
I am unsure why node is looking for a 'lib' folder when all the web3 packages in node_modules have 'src' folders. In case anyone is wondering, I am running npm v8.6.0 and node v16.14.2 (also tried with node v14.17.2 and got same errors).
When you see this error message, usually means your web3 installation was failed/uncompleted. the path node_modules/web3/lib/ exists in successful installation.
I guess some tools are missing in your environment.
I am trying to create snowpack config file for my preact application. I have already installed all necessary libraries but it still show an error when I try to run this command snowpack init. error zsh: command not found: snowpack
This is my package.json file
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"author": "EF",
"license": "MIT",
"scripts": {
"start": "snowpack dev --port 3000",
"build": "snowpack build"
},
"devDependencies": {
"#prefresh/snowpack": "^3.1.2",
"snowpack": "^3.8.8"
},
"dependencies": {
"preact": "^10.5.15"
}
}
What could be the problem here?
The problem is that the snowpack binary isn't in your $PATH. The only time it should be is if you globally installed it. But because you haven't, you cannot access it.
There's an easy solution (and the correct way to run binaries) and that is using npx or yarn. Either will do the trick, so whichever you prefer.
npx snowpack ... or yarn snowpack ... from within your project will be able to access the snowpack binary and run it correctly.
I have created git repository which will be used as npm package in other project. Lets say that sharable repository name is genesis-service-broker.
I am using this shareable repository inside one of the service(activation service). In this project, I am installing package using yarn. Its running perfectly fine here.
"dependencies": {
...
"genesis-service-broker": "git+https://${key}:x-oauth-basic#git.my_project.com/${user}/genesis-service-broker.git#create_service_broker_for_genesis",
...
}
When I am trying to use genesis-service-broker package inside onother service(partner service) its not able to install the dependencies. In this project, I am installing dependencies using npm. If I install dependencies using yarn its working perfectly fine.
I am not getting any errors in npm install command. I am just not able to find genesis-service-broker folder inside node_modules, when I am installing dependencies using npm.
package.json file inside genesis-service-broker repository. (for reference purposes)
{
"name": "service-broker",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git#git.my_project.com:amol.barewar/service-broker.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"config": "^3.2.5",
"form-data": "^3.0.0",
"node-fetch": "^2.6.0",
"request": "^2.88.0",
"uuid": "^3.4.0"
}
}
there is a difference in behaviour here, between yarn and npm
yarn add retains the name of the git project in dependencies, and creates a folder with the same name in node_modules.
So, yarn add git+https://${key}:x-oauth-basic#git.my_project.com/${user}/genesis-service-broker.git#create_service_broker_for_genesis will lead to a module getting installed as node_modules/genesis-service-broker
On the other side, npm install gets the name from the name property in package.json; and it will lead to module getting added as node_modules/service-broker in your case... and also the dependencies map will be like
"dependencies": {
...
"service-broker": "git+https://${key}:x-oauth-basic#git.my_project.com/${user}/genesis-service-broker.git#create_service_broker_for_genesis",
...
}
Because of this difference, the requires(...) might fail.
As, in this case, with yarn that module will be available through -
require('genesis-service-broker')
And for npm through -
require('service-broker')
So, all in all, it will help to keep the name property in package.json same as the project name.
The sass folders and files are in the correct place. What is wrong?
I have the package.json which I created, with this code in there.
{
"name": "starter",
"version": "1.0.0",
"description": "starter file",
"main": "index.js",
"scripts": {
"compile:sass": "node-sass sass/main.scss css/style.css -w"
},
"author": "Nez",
"license": "ISC",
"devDependencies": {
"node-sass": "^4.12.0"
}
}
As you can see the script is called compile sass when I try to run it it keeps giving the error
npm ERR! missing script: compile:sass
I have the sass compiler installed already as a dev dependency
I had this happen as well. The only way I could fix it was to move my files out of my dropbox folder on an external hard drive and move them to my main computers' hard drive. I think it has something to do with Dropbox, but I'm not sure.
One of your sass files has a syntax error
eg.
file 1 has
background: %pink
the %pink value is undefined you should check your files if %pink* is implemented
I had the same issue and tried everything until I simply saved the project files within my code editor and then all of a sudden it worked.
Add this to your code all you need to do is add npx before your node
I.e. npx node...
Then go to your terminal to that directory and run this command npm run compile:sass
Hope this works...because it worked for me will work for you too
I think you should check your file path
After 3 years!
for me it's solved by rewriting the package.json "scripts" line :
"compile:sass": "node-sass sass/main.scss css/style.css -w"
Go to package.json
Add below lines
"scripts": {
"sass": "sass sass/main.scss css/style.css",
"test": "echo \"Error: no test specified\" && exit 1"
},
For compilation use command:
npm run sass
Note: I have used main.scss as source file name
I'm stuck with a problem when building my Node JS/electron app with electron-builder. It works perfectly when running npm start. But, when I execute the command build -w (for windows) it fails with this log.
Here is my JSON file:
{
"name": "Munshiiii",
"version": "1.0.0",
"description": "This is a short Description of the project",
"main": "index.js",
"scripts": {
"start": "electron .",
"dist": "build -w"
},
"author": "Hicham Dbiza",
"license": "ISC",
"devDependencies": {
"electron": "1.7.8",
"electron-prebuilt": "^1.4.13"
},
"dependencies": {
"asar": "^0.13.0",
"cradle": "^0.7.1",
"fs": "0.0.1-security",
"git": "^0.1.5",
"jquery": "^3.2.1",
"jsdom": "^11.3.0",
"loke-ipc": "^1.0.5",
"mongodb": "^2.2.33",
"node-couchdb": "^1.2.0",
"pouchdb": "^6.3.4",
"pouchdb-replication-stream": "^1.2.9",
"scanner.js": "^1.0.0"
},
"build":{
"appId": "com.hicham.dbiza.faizan",
"win":{
"target": "nsis",
"icon": "build/Munshiiii.ico"
}
}
}
for this project Im using:
fs
pouchdb
electron
jquery
....
I already used electron-packager and it works almost fine with one problem: See this picture, which means all links inside the js files (e.g: fs.readFileSync('./assets/state','utf8')) won't work.
I have also added some native js click and keypress listeners... could that be a problem?
My electron version is 1.7.8.
I appreciate your help.
Yarn is strongly recommended instead of npm.
yarn add electron-builder --dev
if you are using Npm
do just simple steps terminal:
1 npm install yarn -g
2 yarn
3 yarn pack
Read this Blog (reactJS in electronApp with .exe file)
Have you installed electron-builder? You don't have it in your package.json. Then I would propose to use the electron-builder command, as recommended by the authors.
Run npm install electron-builder --save-dev and change your dist command to run just electron-builder. Since electron-builder per default build for the current running OS, it's not necessary to send the -w flag. If you still experience problems, try to set the following env variable to get a better stack trace:
DEBUG=electron-builder,electron-builder:*
Edit after getting more information from the comments:
According to this issue at GitHub your first issue seemed to be caused by permission errors, and was solved with running as administrator.
From electron-builders README:
Yarn is strongly recommended instead of npm.
yarn add electron-builder --dev
Try to remove your node_modules folder and run
npm install yarn -g && yarn && yarn pack
First I installed electron-builder with following line
npm install -g electron-builder
then I created a build folder in the root of my project, containing the .ico file with the app logo. then I wrote following parts in my package.json
"build": {
"appId": "your.app.id",
"productName": "Your final product name"
}
and
"scripts": {
"start": "electron .",
"pack": "build --dir"
}
That was everything I needed. I opend my root folder in the terminal and executed
build -w
That created an folder called dist, with an unpacked version of my app plus an installer for the app.