Browser Sync Error - 'Cannot GET/' - javascript

I'm currently using Browser Sync newest version (2.24.6) installed via npm install -g browser-sync and I did so in my C:\Users\USERNAME\Google Drive I am using Gulp.
I start browser sync by running browser-sync start --server --files '*.html, css/*.css, js/*.js' in bash and my project opens up. The project updates as expected when I change HTML, CSS, and/or JS files.
However, when I edit my package.json file (which is not in the same directory) under "scripts" with "start": browser-sync start --server --files '*.html, css/*.css, js/*.js' and then run npm start in my bash console I get a page but all I see is Cannot GET / and not my project.
Also, if I try to browser-sync start --server --files '*.html, css/*.css, js/*.js' or in any other project I get the same error.
If I do gulp browser-sync this is what I get:
[06:03:14] Working directory changed to ~\Google Drive
[06:03:15] Using gulpfile ~\Google Drive\gulpfile.js
[06:03:15] Starting 'browser-sync'...
[Browsersync] Access URLs:
--------------------------------------
Local: http://localhost:3000
External: http://192.168.1.116:3000
--------------------------------------
UI: http://localhost:3001
UI External: http://192.168.1.116:3001
--------------------------------------
[Browsersync] Serving files from: ./
Here is my gulpfile.js :
const gulp = require("gulp");
const browserSync = require('browser-sync').create();
gulp.task('browser-sync', function () {
browserSync.init({
server: {
baseDir: './',
}
});
});
And here is my package.json file:
{
"name": "eslint-test",
"version": "1.0.0",
"description": "",
"main": "main.js",
"dependencies": {
"browser-sync": "^2.24.6",
"gulp-sass": "^4.0.1"
},
"devDependencies": {
"eslint": "^4.18.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.9.0",
"gulp": "^4.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "browser-sync start --server --files '*.html, css/*.css, js/*.js'"
},
"author": "",
"license": "ISC"
}
I apologize if this is not the right place but I have searched and watched videos for about 2 hours with no answers found. I appreciate any and all help/links.

Related

a dynamic link library (dll) initialization routine failed when build electron

error that when i run builded electron program
the program operate well in my computer but,when i build by 'electron-builder --win portable' and move to other computer then the error occured. (coding in window 11, test in window 10)
how do i fix it?
package.json
"scripts": {
"build:renderer": "webpack --config ./client/webpack.config.renderer.js",
"build:main": "tsc --project ./client/tsconfig.json",
"build": "npm run build:main && npm run build:renderer",
"build:addon:x86": "(cmake-js -G \"Visual Studio 16 2019\" -A Win32 -O build_Win32)",
"build:addon:x64": "(cmake-js -G \"Visual Studio 16 2019\" -A x64 -O build_x64)",
"start": "electron . --enable-logging",
"copy_binary": "copy_binary.bat",
"dist": "electron-builder --win portable"
},
"devDependencies": {
"cmake-js": "^7.0.0",
"electron-rebuild": "^3.2.7",
"ts-loader": "^9.4.1",
"typescript": "^3.1.0",
"webpack": "^5.74.0",
"electron": "16.0.10",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"node-addon-api": "^4.1.0"
},
"cmake-js": {
"runtime": "electron",
"runtimeVersion": "16.0.10"
}
i tried that...
add "postinstall": "electron-builder install-app-deps" in package.json
add set(DELAY_LOAD_HOOK "hook/win_delay_load_hook.cc") in cmakelists.txt
I managed to fix it copying the old binding.gyp file and ran electron-rebuild, the new .node file will be here .\electron-overlay\bin\win32-x64-109

after the command "npm start" I do not see changes in the console, as if the code is not being updated on the fly. JS

after the command "npm start" I do not see changes in the console, as if the code is not being updated on the fly.
{
"scripts": {
"format": "prettier --write app",
"start": "http-server"
},
"dependencies": {
"http-server": "^14.1.0"
},
"devDependencies": {
"prettier": "^2.0.5"
}
}
My version of node: 7.11.1
i have a macbook
What can I do ?
Thank you
Node do not automatically restart after changes :)
You should use eg. nodemon:
https://www.npmjs.com/package/nodemon
npm i nodemon --dev
Then start your app like that:
nodemon index.js
donnot reload your page.
you can use eg. nodemon: https://www.npmjs.com/package/nodemon
Thank you for your help, but it still doesn't go ... I installed a nodemon. {
"scripts": {
"format": "prettier --write app",
"start": "http-server"
},
"dependencies": {
"http-server": "^14.1.0"
},
"devDependencies": {
"nodemon": "^2.0.16",
"prettier": "^2.0.5"
}
}
then I have to in the console: nodemon game.js ?

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}`)
});

Travis CI fails on tsc

So I have a typescript project hosted on github.
I'm trying to set up Travis CI for tests but when I get to the step to compile the code to javascript (tsc command) it fails.
The error looks like this:
> node node_modules/typescript/bin/tsc
src/DbHandler.ts:2:32 - error TS2307: Cannot find module './models/User'.
2 import { User, UserInit } from './models/User';
~~~~~~~~~~~~~~~
src/User.ts:2:22 - error TS2307: Cannot find module './models/User'.
2 import { User } from "./models/User";
~~~~~~~~~~~~~~~
Found 2 errors.
npm ERR! code ELIFECYCLE
The paths to the files ARE correct and it compiles just fine locally..
In the project I have this package.json(cleaned):
{
"name": "project",
"version": "0.0.1",
"description": "",
"main": "dist/server.js",
"scripts": {
"build": "node node_modules/typescript/bin/tsc",
"prod": "node dist/server.js",
"dev": "ts-node src/server.ts",
"dev:watch": "nodemon",
"test:watch": "ts-node node_modules/jasmine/bin/jasmine",
"test": "node node_modules/jasmine/bin/jasmine.js --config=jasmine.json"
},
"author": "myname",
"license": "MIT",
"devDependencies": {
"#types/express": "~4.17.1",
"#types/jasmine": "~3.4.4",
"jasmine": "~3.5.0",
"nodemon": "~1.19.4",
"ts-node": "~8.4.1",
"tslint": "~5.20.0",
"typescript": "~3.6.4"
},
"dependencies": {
"express": "~4.17.1"
}
}
And my .travis.yml looks like:
language: node_js
cache: npm
node_js:
- "stable"
install:
- npm ci
- npm run build
script:
- npm run test
And my file structure is something like this:
package.json
.travis.yml
src/
models/
User.ts
DbHandler.ts
User.ts
server.ts
test/
files_for_tests_with_ts_extension

webpack + babel not bundling the js properly

I am using webpack and babel in my project. While the webpack is wokring fine but babel is somehow not doing it's job in polyfilling the ES6+ features. When I use the npm script, I get some error "Entrypoint undefined = index.html" in the command prompt. Kindly help !
Package.json
{
"name": "forkify",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"author": "neeraj",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.2",
"babel-preset-env": "^1.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.19.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
},
"dependencies": {
"babel-polyfill": "^6.26.0"
}
}
webpack.config.js
const path=require('path');
const HtmlWebPackPlugin=require('html-webpack-plugin');
module.exports={
entry:['babel-polyfill','./src/js/index.js'],
output:{
path:path.resolve(__dirname,'dist'),
filename:'js/bundle.js'
},
devServer:{
contentBase:'./dist'
},
plugins:[
new HtmlWebPackPlugin({
filename:'index.html',
template:'./src/index.html'
})
],
module:{
rules:[
{
test:/\.js$/,
exclude:/node_modules/,
use:{
loader:'babel-loader'
}
}
]
}
};
.bablerc
{
"presets":[
["env",{
"targets":{
"browser":[
"last 5 versions",
"ie>=8"
]
}
}]
]
}
Error what I get:
Project Structure:
EDIT------------------
I started getting some new error now.
It is the html-webpack-plugin's problem, a fix was introduced in
3.0.7 but was removed again in 3.0.8. For more information, please click here.
So if you run npm install --save-dev html-webpack-plugin#3.0.7, and then npm run dev will output Entrypoint html-webpack-plugin for "index.html" = index.html. And personally, it is a trivail problem not that important.
There was some dependency issue. Deleted my node_modules folder and used this command instead: npm install -D babel-loader#7 babel-core babel-preset-env webpack
Follow this link for more information : https://github.com/babel/babel-loader
Now I no longer get any error and also babel is working fine.
FYI....you might have to install babel-polyfill & html-webpack-plugin seperately.

Categories

Resources