Gulp : SyntaxError: missing ) after argument list - gulp

I have a project which builds successfully on an Apple Mac but produces the following error when trying to run a gulp task on Windows:
project\node_modules\.bin\gulp:2
basedir=$(dirname $(echo "$0" | sed -e 's,\\,/,g'))
^^^^^^^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
package.json
"scripts": {
"gulp": "node node_modules/.bin/gulp",
"build-local": "npm run gulp build-local",
},
"devDependencies": {
"gulp": "3.9.1",
"gulp-angular-templatecache": "~2.0.x",
"gulp-autoprefixer": "^4.0.0",
"gulp-concat": "~2.6.x",
"gulp-live-server": "^0.0.31",
"gulp-minify-html": "~1.0.x",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "~2.5.x",
"gulp-stylelint": "^5.0.0",
"gulp-uglify": "~2.1.x",
It it helps I'm using an old version of Node (10.0.0) because the project is quite dated

Related

SyntaxError: Cannot use import statement outside a module in gulp

hi i will try to learn gulp but at start i have an error in my simple hello world. can anybody help me?
my gulp version is:
CLI version 3.9.0
Local version 4.0.2
my .babelrc file :
{
"presets": [ "#babel/preset-env" ]
}
my gulpfile.babel.js file :
export const hello = (done) => {
console.log('hello');
done();
}
my package.json file :
"name": "meatheme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"start": "gulp",
"build": "gulp build --prod",
"bundle": "gulp bundle --prod"
},
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.12.3",
"#babel/preset-env": "^7.12.1",
"#babel/register": "^7.12.1",
"babel-loader": "^8.1.0",
"browser-sync": "^2.26.13",
"del": "^5.1.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^7.1.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.0.0",
"gulp-sass": "^5.0.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-uglify": "^3.0.2",
"gulp-wp-pot": "^2.5.0",
"gulp-zip": "^5.0.2",
"sass": "^1.43.4",
"vinyl-named": "^1.1.0",
"webpack-stream": "^5.2.1",
"yargs": "^15.4.1"
},
"dependencies": {
"#fortawesome/fontawesome-free": "^5.15.1",
"jquery": "^3.5.1",
"normalize.css": "^8.0.1",
"slick-carousel": "^1.8.1"
}
}
and when i run gulp hello is see this in terminal.
[16:47:07] Failed to load external module babel-core/register
[16:47:07] Failed to load external module babel/register
/home/mehdi/Work/Meacodes/Mea template/mea0.1/gulpfile.babel.js:16
import gulp from 'gulp';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.execute (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:203:12)
at module. Exports (/usr/local/lib/node_modules/gulp/node_modules/flagged-respawn/index.js:51:3)
do you know where is my issue?
I was advised to write "type": "module" to file package.json to the very end of the file
since node otherwise does not consider js files as ES modules, outside of which you still cannot use the import statement)
(in the browser we do modules through the type attribute of the script tag)

ES Module error encountered when testing npm package locally

Background:
I am trying to test an npm package that I am developing: a React Component that manages a SVG filter animation. In verifying that it works as expected, I have used npm pack to generate a tarball, which I have then installed as a dependency in another project (one I expect to consume said package when properly published).
To make this easier, I will refer to the npm package I am developing as package A and refer to the project that consumes it as project B. Please take note of the technologies mentioned below as their giving context will likely provide insight.
Relevant Technologies
packageA
node: 14.18.1
esbuild: ^0.11.11
typescript: ^4.2.3
projectB
node: 14.18.1
remix: 1.4.1
typescript: ^4.2.3
Observations + Problems:
Observations:
npm pack, when run in package A, spits out a tarball that includes everything BUT the output build directory of package A.
package A has a package.json with a type field set as "module", thereby declaratively supporting ES Module System syntax.
npm install of this tarball in project B is successful.
If I change my import of package A to its absolute path (node_modules/projectA/build/main.js) in project B's node_modules I avoid the problem defined in Problems #1.
Problems:
Any attempt to consume package A in project B is met with the following error:
// THIS IMPORT
// projectB > index.js
import PackageAComponent from 'packageA'
// RESULTS IN:
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/jackwilliammorris/Code/better-brain-blogging/node_modules/fuzzy-scrawl/build/esbuild/browser.js
require() of ES modules is not supported.
require() of /Users/jackwilliammorris/Code/better-brain-blogging/node_modules/fuzzy-scrawl/build/esbuild/browser.js from /Users/jackwilliammorris/Code/better-brain-blogging/server/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename browser.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/jackwilliammorris/Code/better-brain-blogging/node_modules/fuzzy-scrawl/package.json.
at new NodeError (internal/errors.js:322:7)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/jackwilliammorris/Code/better-brain-blogging/app/routes/braindumps/index.tsx:8:25)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
Relevant Code Snippets
// projectB package.json
{
"name": "projectB",
"private": true,
"description": "",
"license": "",
"sideEffects": false,
"scripts": {
... ,
"dev": "run-p dev:*",
"dev:arc": "node ./dev sandbox",
"dev:css": "npm run generate:css -- --watch",
"dev:remix": "remix watch",
...
},
"prettier": {},
"dependencies": {
"#architect/architect": "^10.2.1",
"#architect/functions": "^5.0.4",
"#happy-dom/jest-environment": "^3.1.0",
"#notionhq/client": "^1.0.4",
"#remix-run/architect": "^1.4.1",
"#remix-run/node": "^1.4.1",
"#remix-run/react": "^1.4.1",
"#remix-run/server-runtime": "^1.4.1",
"bcryptjs": "2.4.3",
"classnames": "^2.3.1",
"cuid": "^2.1.8",
"fuzzy-scrawl": "file:../fuzzy-scrawl/fuzzy-scrawl-0.0.0.tgz",
"highlight.js": "^11.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"tiny-invariant": "^1.2.0"
},
"devDependencies": {
"#faker-js/faker": "^6.1.1",
"#remix-run/dev": "^1.4.1",
"#remix-run/eslint-config": "^1.4.1",
"#testing-library/cypress": "^8.0.2",
"#testing-library/jest-dom": "^5.16.3",
"#testing-library/react": "^12.1.4",
"#testing-library/user-event": "^14.0.4",
"#types/architect__functions": "^3.13.6",
"#types/bcryptjs": "2.4.2",
"#types/eslint": "^8.4.1",
"#types/jest": "^27.4.1",
"#types/react": "^17.0.43",
"#types/react-dom": "^17.0.14",
"#vitejs/plugin-react": "^1.3.0",
"c8": "^7.11.0",
"cross-env": "^7.0.3",
"cypress": "^9.5.3",
"esbuild": "^0.14.29",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"happy-dom": "^2.55.0",
"jest": "^27.5.1",
"mock-aws-s3": "^4.0.2",
"msw": "^0.39.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.1",
"prettier-plugin-tailwindcss": "^0.1.8",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^3.0.23",
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"vitest": "^0.8.2"
},
"engines": {
"node": "14"
}
}
// packageA package.json
{
"name": "fuzzy-scrawl",
"version": "0.0.0",
"author": "slackermorris",
"repository": "",
"license": "MIT",
"keywords": [
"css",
"typescript",
"scss"
],
"main": "./build/main.js",
"module": "./build/main.js",
"type": "module",
"types": "./build/tsc/main.d.ts",
"scripts": {
"esbuild-browser:dev": "NODE_ENV=development node build esbuild-browser:dev",
},
"devDependencies": {
"#types/jest": "^26.0.21",
"#types/node": "^15.0.1",
"#types/react": "^18.0.15",
"#types/react-dom": "^18.0.6",
"#typescript-eslint/eslint-plugin": "^4.19.0",
"#typescript-eslint/parser": "^4.19.0",
"esbuild": "^0.11.11",
"esbuild-css-modules-plugin": "^2.3.2",
"esbuild-plugin-css-modules": "^0.1.3",
"esbuild-sass-plugin": "^2.2.6",
"esbuild-style-plugin": "^1.6.0",
"eslint": "^7.22.0",
"jest": "^26.6.3",
"live-server": "^1.2.2",
"sass": "^1.53.0",
"ts-jest": "^26.5.4",
"ts-node": "^9.1.1",
"typedoc": "^0.20.35",
"typescript": "^4.2.3"
},
"dependencies": {
"gsap": "^3.10.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

Angular boot error npm ERR! code ELIFECYCLE

I have this problem when I want boot Angular project
tried install plugins
{
"name": "portal-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.0.0",
"#angular/common": "^5.0.0",
"#angular/compiler": "^5.0.0",
"#angular/core": "^5.0.0",
"#angular/forms": "^5.0.0",
"#angular/http": "^5.0.0",
"#angular/platform-browser": "^5.0.0",
"#angular/platform-browser-dynamic": "^5.0.0",
"#angular/router": "^5.0.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"#angular/cli": "^1.6.3",
"#angular/compiler-cli": "^5.0.0",
"#angular/language-service": "^5.0.0",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
You have to be inside an angular-cli project in order to use the
serve command.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! portal-app#0.0.0
start: ng serve --proxy-config proxy.config.json npm ERR! Exit
status 1 npm ERR! npm ERR! Failed at the portal-app#0.0.0 start
script. npm ERR! This is probably not a problem with npm. There is
likely additional logging output above. npm WARN Local package.json
exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\User\AppData\Roaming\npm-cache_logs\2019-04-24T06_32_19_277Z-debug.log
Process finished with exit code 1
Your error is clear and meaningful : you need to be inside your project to run your command. You'll maybe need to use the change directory command to place your command prompt at the right location before launching your npm scripts.
So :
cd /path/to/projectDirectory
npm start
Should do the trick.
in my case I got this type of error when running ng test --karma-config=karma.conf.js --code-coverage, and the cause of problem were console.log statements in the code

Feathersjs Error handling issue

Have an issue with feathersjs-authentication. Calling a service which requires authorization without an Authorization header causes this stacktrace in console:
at Object.<anonymous> (/User Analytics/Backend/node_modules/feathers-
errors/lib/index.js:69:27)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/User Analytics/Backend/node_modules/feathers-
rest/lib/wrappers.js:13:23)
at Module._compile (module.js:571:32)
client receives even more strange response:
{
"name": "GeneralError",
"message": "`toJSON` takes 0 argument, 1 provided
after:\nr.db(\"user_analytics\").table(\"fbusers\")",
"code": 500,
"className": "general-error",
"data": {},
"errors": {}
}
Client receives GeneralError instead of concrete error and proper code.
Dependency packages:
"dependencies": {
"body-parser": "^1.17.2",
"compression": "^1.6.2",
"cors": "^2.8.3",
"fb": "^2.0.0",
"feathers": "^2.1.3",
"feathers-authentication": "^1.2.6",
"feathers-authentication-hooks": "^0.1.4",
"feathers-authentication-jwt": "^0.3.1",
"feathers-authentication-local": "^0.4.3",
"feathers-configuration": "^0.4.1",
"feathers-errors": "^2.8.1",
"feathers-hooks": "^2.0.1",
"feathers-hooks-common": "^3.5.5",
"feathers-rest": "^1.7.3",
"feathers-rethinkdb": "^0.4.3",
"feathers-socketio": "^2.0.0",
"helmet": "^3.6.1",
"lodash": "^4.17.4",
"node-rest-client": "^3.1.0",
"rethinkdbdash": "^2.3.29",
"serve-favicon": "^2.4.3",
"winston": "^2.3.1"
},

Why doesnt my project have a node_modules folder

Is there a yarn equivalent of node_modules folder?
I have a new MERN project folder. It has a package.json file. The package.json file includes dependencies and dev dependencies for babel (full list below):
"dependencies": {
"axios": "^0.16.1",
"babel-cli": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-polyfill": "^6.13.0",
"body-parser": "^1.17.1",
"caniuse-api": "^2.0.0",
"express": "^4.13.4",
"lodash": "^4.17.4",
"material-ui": "^0.18.0",
"nodemon": "^1.11.0",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-promise": "^1.1.2",
"react-redux": "^5.0.4",
"react-router": "^4.1.1",
"react-tap-event-plugin": "^2.0.1",
"redux": "^3.6.0",
"redux-devtools": "^3.4.0",
"redux-form": "^6.7.0",
"redux-thunk": "^2.2.0",
"socket.io": "^2.0.1",
"source-map-support": "^0.4.15"
},
"devDependencies": {
"babel": "^6.23.0",
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babelify": "^7.3.0",
"enzyme": "^2.8.2",
"mocha": "^3.3.0",
"react-addons-test-utils": "^15.5.1",
"webpack": "^2.5.1"
}
I'm trying to use import statements instead of require statements. I think that should work because I have babel dependencies, but when I try to run npm start, I get an error that says:
/server.js:2
import bodyParser from 'body-parser';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
[nodemon] app crashed - waiting for file changes before starting...
Is there something wrong with trying to use npm start if you use yarn? Should I be trying to find an equivalent command line start statement because I have used yarn instead of npm?
I have npm installed. I don't understand why I don't have a node modules folder?