Yarn encore prod failing - ubuntu-18.04

Im trying to deploy a symfony application on my Ubuntu server.
Mind the following details.
It is a simple application but some yarn packages seem to be failing.
What can I do?
Im working with Symfony 5.
My package.json
{
"devDependencies": {
"#symfony/webpack-encore": "^0.30.2",
"bootstrap": "^4.5.2",
"jquery": "^3.5.1",
"node-sass": "^4.14.1",
"popper.js": "^1.16.1",
"webpack-notifier": "^1.6.0"
},
"dependencies": {
"add": "^2.0.6",
"copy-webpack-plugin": "^6.0.3",
"sass-loader": "^8.0.0",
"yarn": "^1.22.4"
},
"name": "fluid-cms",
"version": "1.0.0",
"main": "index.js",
"repository": "---",
"author": "---",
"license": "MIT"
}
The following output comes out.
I have tried many things.
Ubuntu 18.04.
alpha#ovhBrains:/var/www/fluid-cms$ sudo yarn encore prod
yarn run v1.22.4
$ /var/www/fluid-cms/node_modules/.bin/encore prod
Running webpack ...
/var/www/fluid-cms/node_modules/copy-webpack-plugin/node_modules/p-limit/index.js:30
} catch {}
^
SyntaxError: Unexpected token {
at NativeCompileCache._moduleCompile (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-cache.js:242:18)
at Module._compile (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/www/fluid-cms/node_modules/copy-webpack-plugin/dist/index.js:10:38)
at Module._compile (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-
d.
---
Another error:
#symfony/webpack-encore#0.30.2: The engine "node" is incompatible with this module. Expected version ">= 10.13.0". Got "8.10.0"

Once I found out the second error log it was easy to fix.
My nodejs -v was not matching with the requirements.

Related

How to use snap SVG in react with next and TS?

Issue
Hello,
I am trying to use SnapSVG in my react project, but I cannot get it to run in the first place. Could someone help me with the proper settings? I am not very familiar with webpack so detailed instructions would be very much appreciated.
error
index.js?46cb:602 Uncaught ReferenceError: window is not defined
at Object.<anonymous> (FILEPATH/node_modules/snapsvg/dist/snap.svg.js:485:3)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.snapsvg (FILEPATH/.next/server/pages/index.js:1291:18)
at
**webpack_require**
(FILEPATH/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///./src/components/domain/top-first-view/index.tsx:9:65)
import in React components
import * as Snap from 'snapsvg';
package.json
"dependencies": {
"next": "^13.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sanitize.css": "^13.0.0",
"sass": "^1.56.1"
},
"devDependencies": {
"typescript": "^4.8.4",
"imports-loader": "^4.0.1",
"snapsvg": "^0.5.1",
"#types/snapsvg": "^0.5.2",
"cjs-loader": "^0.1.0",
...
},
"volta": {
"node": "18.6.0",
"yarn": "1.22.19"
}
what I've tried so far
I have tried using imports-loader as is discussed in this Github thread, but this resulted in a new error.
new error after webpack settings
Uncaught Error: ENOENT: no such file or directory, open 'FILEPATH/.next/server/pages/index.js'
at Object.openSync (node:fs:594:3)
at Object.readFileSync (node:fs:462:35)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1143:18)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.requirePage (FILEPATH/node_modules/next/dist/server/require.js:88:12)
at <unknown> (FILEPATH/Documents/GitHub/toda-web-art/node_modules/next/dist/server/load-components.js:37:73)
at async Object.loadComponents (FILEPATH/node_modules/next/dist/server/load-components.js:37:26)
webpack config in next.config.js
webpack(config) {
config.module.rules.push(
{
test: require.resolve('snapsvg'),
use: 'imports-loader?this=>window,fix=>module.exports=0',
},
...
Thank you!

failing to run locally create-react-app. npm start gives a syntax error

I'm trying to locally run and debug my client's site but I cannot get it to start locally. I tried updating npm but with no sucess. This site was made with create react app. I am not sure if something wrong is with the code, with my npm or maybe I'm not seeing something very obvious.
I use git clone, then npm i, then npm start and this happens:
compiler.hooks.done.tap('done', async stats => {
^^^^^
SyntaxError: missing ) after argument list
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.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/filipsikora/Downloads/avrio-shop2-react-1.1/node_modules/react-scripts/scripts/start.js:45:5)
at Module._compile (module.js:570:32)
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.require (module.js:497:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shop_2.0#0.1.0 start: `react-app-rewired start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the shop_2.0#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I know that it highlights the word async. I tried to update npm in many ways. Maybe I screwed something up and not updated it correctly.
Here is my package.json just in case
{
"name": "shop_2.0",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.1",
"bootstrap": "^4.5.3",
"firebase": "^6.6.2",
"node-sass": "^4.14.1",
"raven-js": "^3.27.2",
"react": "^16.14.0",
"react-app-rewire-disable-chunks": "0.0.1",
"react-app-rewired": "^2.1.6",
"react-dom": "^16.14.0",
"react-google-recaptcha": "^1.1.0",
"react-horizontal-scrolling-menu": "^0.7.8",
"react-localization": "^1.0.15",
"react-redux": "^6.0.1",
"react-redux-toastr": "^7.6.5",
"react-router-dom": "^5.2.0",
"react-scripts": "2.1.8",
"react-scrollbar": "^0.5.6",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-app-rewired start",
"watch": "node scripts/build-watch.js",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"eslint-plugin-react": "^7.21.5"
},
"homepage": "/plugin/shop-app"
}

Problem starting a react-native app in simulator

This is my package.json
{
"name": "Locals",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"#babel/runtime": "^7.3.1",
"react": "16.6.3",
"react-native": "0.58.3",
"react-native-elements": "^1.0.0",
"react-native-vector-icons": "^6.2.0"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
And I get following logs of failure:
Loading dependency graph, done. error: bundling failed: Error: Cannot
find module 'NativeModules'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.get NativeModules [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native/Libraries/react-native/react-native-implementation.js:313:12)
at Object.get [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/react-native.js:1:344)
at Object. (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/ensure-native-module-available.js:1:238)
at Module._compile (internal/modules/cjs/loader.js:689:30)
Run rm -rf node_modules && npm install to reinstall the dependencies.
Make sure that react-native-vector-icons is properly linked. Usually you should have this line within android/app/build.gradle:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
More info here:
https://github.com/oblador/react-native-vector-icons#android
Kill the npm server (ctrl+c or just run kill -15 [pid]) and restart it using npm start -- --reset-cache
Finally, don't forget to rebuild your app:
./android/gradlew clean && react-native run-android

Installing React-native calendars breaks installation

I'm a bit puzzled why two different npm installs for a react-native calendar are breaking the solution. I am running react-native through expo, and it runs fine before installing the calendar.
But after installing either
react-native-general-calendars
or
react-native-calendars
I get this error in the console after running
expo start:
> [17:30:29] Starting project at --location--
[17:30:33] Error: React native is not installed. Please run `npm install` in your project directory.
[17:30:33] Couldn't start project. Please fix the errors and restart the project.
[17:30:33] Set EXPO_DEBUG=true in your env to view the stack trace.
I run npm install and get the following error:
> [17:33:34] Starting project at --location--
[17:33:40] --location--\node_modules\react-native\local-cli\server\checkNodeVersion.js:43
[17:33:40] );
[17:33:40] ^
[17:33:40] SyntaxError: Unexpected token )
[17:33:40] at createScript (vm.js:56:10)
[17:33:40] at Object.runInThisContext (vm.js:97:10)
[17:33:40] at Module._compile (module.js:542:28)
[17:33:40] at Object.Module._extensions..js (module.js:579:10)
[17:33:40] at Module.load (module.js:487:32)
[17:33:40] at tryModuleLoad (module.js:446:12)
[17:33:40] at Function.Module._load (module.js:438:3)
[17:33:40] at Module.require (module.js:497:17)
[17:33:40] at require (internal/module.js:20:19)
[17:33:40] at Object.<anonymous> (--location--\node_modules\react-native\local-cli\cli.js:17:1)
[17:33:40] Metro Bundler process exited with code 1
[17:33:40] Set EXPO_DEBUG=true in your env to view the stack trace.
Here is my package.json:
{
"name": "my-new-project",
"main": "node_modules/expo/AppEntry.js",
"private": true,
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/samples": "2.1.1",
"expo": "^29.0.0",
"react": "^16.4.2",
"react-native": "^0.56.0",
"react-native-general-calendars": "^1.7.2",
"react-navigation": "^2.9.3"
},
"devDependencies": {
"jest-expo": "^29.0.0"
}
}
When I uninstall the calendar I still get the error now. Not sure how to get expo to stop throwing the error. Anyone know how to fix this?

SyntaxError: Unexpected token :

I am following Angular 2 quickstart here
I am getting following error on npm start:
angular-quickstart/bs-config.js:2
"server": {
^
SyntaxError: Unexpected token :
at Object.exports.runInThisContext (vm.js:76:16)
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.require (module.js:497:17)
at require (internal/module.js:20:19)
Here is my bs-config.json
{
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
}
}
}
And here is my package.json:
{
"name": "angular-quickstart",
"version": "1.0.0",
"scripts": {
"start": "npm run lite",
"lite": "lite-server"
},
"license": "MIT",
"dependencies": {
"#angular/common": "~2.4.0",
"#angular/compiler": "~2.4.0",
"#angular/core": "~2.4.0",
"#angular/forms": "~2.4.0",
"#angular/http": "~2.4.0",
"#angular/platform-browser": "~2.4.0",
"#angular/platform-browser-dynamic": "~2.4.0",
"#angular/router": "~3.4.0",
"#angular/upgrade": "~2.4.0",
"angular-in-memory-web-api": "~0.2.4",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.7.4"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2"
}
}
I've latest node:
node -v
v7.5.0
And I've latest nam:
npm -v
4.1.2
Here is my directory structure:
ls
bs-config.js node_modules npm-debug.log package.json src
bs-config.js should be an JSON bs-config.json object.

Categories

Resources