node_modules is not recognized as an internal or external command - javascript

I'm trying to write a test automation script using appium, jasmine, and perfecto mobile. I'm using the project cloned from the following URL with my own configuration Appium Javascript Example
The problem is when I execute the npm test command I get the following error
node_modules is not recognized as an internal or external command
This is how the packages.json script looks like:
{
"name": "perfecto_appium_sample",
"version": "1.0.0",
"description": "The following sample shows how to Install an application and use WebDriverIO to automate and test it.<br/> It uses selendroid test application which can be downloaded from [here](https://github.com/PerfectoCode/AppsForSamples/tree/master/selendroid-test-app-0.17.0).",
"main": "perfectoSpec.js",
"scripts": {
"test": "node_modules/webdriverio/bin/wdio wdio.conf.js",
"start": "wdio wdio.conf.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"wdio": "^0.3.3",
"wdio-jasmine-framework": "^0.2.19",
"wdio-mocha-framework": "^0.5.12"
},
"dependencies": {
"wd": "^1.5.0",
"webdriverio": "^4.10.2"
},
"keywords": []
}

you need to provide relative path properly:
"scripts": {
"test": "node ./node_modules/webdriverio/bin/wdio wdio.conf.js",
"start": "wdio wdio.conf.js"
}

Just remove the paths "node_modules/webdriverio/bin/" and simply specify "wdio wdio.conf.js". It should work.

Related

Why can I no longer minify my Javascript files?

I am using VS Code to maintain a Javascript library I created and I used Google Closure Compiler (CC) to minify the js file. I have made some changes to the original code but although CC executes without any warning/error messages it fails to create the output file.
This is the package.json file
{
"name": "canvas-gui",
"version": "1.0.0",
"description": "On canvas GUI for p5.js",
"main": "main.js",
"scripts": {
"tsc": "tsc",
"typedoc": "npx typedoc",
"gcc": "npx google-closure-compiler src_js --js_output_file dist/lib/gui.min.js --language_in ECMASCRIPT_2020 --language_out ECMASCRIPT_NEXT"
},
"keywords": [
"GUI",
"canvas",
"p5.js"
],
"author": "Peter Lager",
"license": "MIT",
"devDependencies": {
"#types/p5": "^1.4.2",
"google-closure-compiler": "^20220803.0.0",
"p5": "^1.4.2",
"typedoc": "^0.23.10",
"typescript": "^4.7.4"
}
}
I researched on the parameter values here and tried changing the source parameter to
--js src/**.js
--js='src_js/**.js'
src_js/canvas_gui.js
--js src_js/canvas_gui.js
--js='src_js/canvas_gui.js'
all without success.
I also set the warning level to VERBOSE but still no messages.

Server running error in parcel by starting the external file index.html I Ignoring the main but it also doesn't work(Build Failed)

[Build Error in parcel # 2.7.0 start when I am trying to add external index.html file in the main I also ignored the main but it also doesn't work for me. Will please someone help me to solve this problem It also not working with JavaScript file when I added externally and also getting error with html file but I want to add the html file but as a solution I try to add JavaScript file but it also doesn't work for me. Will please someone solve this issue or tell me how to solve this issue
{
"name": "forkify",
"version": "1.0.0",
"description": "",
"main": "unrelated.js",
"targets": {
"main": false
},
"scripts": {
"start": "parcel start index.html",
"build": "parcel build index.html"
},
"author": "Meelad Sultan",
"license": "ISC",
"devDependencies": {
"parcel": "^2.7.0"
}
}
enter code here
At last I can find the solution of my problem after almost a day if someone else facing the same problem they just do add the **Browsers list ** in the package.json file before script and ignore the main target and also set the parcel to latest then the parcel will run successfully and do not give any server error or build error. And don't forget to run periodically npx browerlist#latest --update-db. It will update your package-lock file with new caniuse-lite version. In this case, you will be sure that last two version or > 0.2% will target what you expect
{
"name": "forkify",
"version": "1.0.0",
"description": "",
"main": "unrelated.js",
"target": {
"main": false
},
"browserslist": "> 0.5%, last 2 versions, not dead",
"scripts": {
"start": "parcel index.html "
},
"author": "Meelad Sultan",
"license": "ISC",
"devDependencies": {
"#parcel/transformer-sass": "^2.7.0",
"parcel": "latest"
},
"dependencies": {
"sass": "^1.55.0"
}
}

Editing package.js file

i'm having a hard time to understand how to run all of my .js files using package.js files
i have almost 2000.js scripts i need to run them one by one, i'm using a api made by gameflip
in the folder i found package.js, but i don't know how to use it ,
can anyone tell me how to do that ? thank you
here the script :
{
"name": "gfapi",
"version": "0.1.1",
"description": "Gameflip API",
"keywords": "Gameflip",
"homepage": "https://github.com/iJJi/gfapi",
"bugs": "https://github.com/iJJi/gfapi/issues",
"author": {
"name": "Eng-Shien Wu",
"email": "engshien.wu#ijji.com"
},
"license": "MIT",
"private": true,
"files": [
"index.js"
],
"repository": "iJJi/gfapi",
"engines": {
"node": ">=8.5.0"
},
"scripts": {
"bulk_listing": "node src/samples/bulk_listing.js",
"test": "ENVIRONMENT=mocha mocha src/test --recursive",
"docs": "jsdoc -c jsdoc_conf.js -d docs -P package.json index.js; docco -o docs/samples src/samples/*.js src/samples/*.rb"
},
"dependencies": {
"base-64": "^0.1.0",
"bluebird": "^3.5.0",
"bunyan": "^1.8.12",
"file-type": "^8.1.0",
"http-errors": "^1.6.2",
"node-rest-client-promise": "^3.1.1",
"promise-ratelimit": "^0.0.3",
"request": "^2.85.0",
"request-promise": "^4.2.2",
"speakeasy": "^2.0.0"
},
"devDependencies": {
"marked": "^0.3.19",
"docco": "^0.7.0",``
"jsdoc": "^3.5.5"
}
}
What you posted isn't a package.js (I don't even know if it exists), but a package.json. It's generated by NPM, the Node Package Manager. It's a list of all the project's dependencies. I think that what you're looking for are the npm scripts, they are in the script object of package.json.
npm run <script>
# For example :
npm run bulk_listing
npm run test
npm run docs
Each script will run its associated command in this package.json.
npm run bulk_listing
# Will do the same thing as:
node src/samples/bulk_listing.js
More about package.json.
The script I talked about below
If you want to run all the scripts, this should do the job :
const fileNames = ["path/to/fileA", "fileB"]; // I assume you have something to get all the files path. Isn't that npm run bulk_listing ?
fileNames.forEach(async (path, index) => {
// It's pretty much like 'node <path>'
await require(path);
// All the code here is executed AFTER the script has been launched
console.log(`LAUNCHED ${index} | ${path}`)
});

How to fix this error "Syntax Error" while running CLI command

I am trying to build a CLI command using Nodejs,
I am using npm link to test my code locally first, and I put my command in the bin section
you can see my package.json below,
and the cli.js is containing only console.log
when I am trying to test "validate-markets-cli" in my cmd I got a popup windows containing this error,
Error: 'console' is not defined.
Code: 800A1391.
Source: Microsoft JScript runtime error.
Here is my package.json
{
"name": "validate",
"version": "1.0.0",
"description": "",
"main": "cli.js",
"scripts": {
"start": "node cli"
},
"bin": {
"validate-markets-cli": "./cli.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"commander": "^2.19.0",
"csvtojson": "^2.0.8",
"lodash": "^4.17.11"
}
}
and this is my cli.js
console.log('test test');
I added this line "#!/usr/bin/env node"
at cli.js and it worked

Lite-server not working

I had a project that was previously using lite-server. I can no longer get it to run using
npm run
I see the following from the console
PS C:\Users\XXX\Documents\Work\Repos\Homepage_Slider> npm run
Lifecycle scripts included in homepage_slider: test
echo "Error: no test specified" && exit 1 start
lite-server
I don't really understand why this isn't working anymore.
I've tried:
Updating NPM
Running lite-server globably
Make sure package.json is set up correctly
Here is my package.json file
{
"name": "homepage_slider",
"version": "1.0.0",
"description": "A simple slider for homepage",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server"
},
"repository": {
"type": "git",
"url": "XXX"
},
"keywords": [
"Slider"
],
"author": "XXX",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.3.0"
},
"dependencies": {
"npm": "^6.0.1"
}
}
npm run is a reserved word for npm itself. Check the documentation
What you really need is npm start which is a shortcut for npm run start which is a shortcut for npm run-script start!

Categories

Resources