gatsby can't fetch all graphql data on vercel production - reactjs

I am working on a Headless eCommerce website using Gatsby, Contentful. Shopify and Nacelle.
It works fine if I run the app using npm run dev, I can see all graphql data from Contentful.
That's what I mean is that all of graphql data can be fetched on the local side even npm run build, but it doesn't compile all of graphql data on production.
Here are some of the logs while building the gatsby app on Vercel.
The logs say that there's no errors, but I can see some of warnings from there.
Here's the graphql query, it works fine on local environment.
const HomePage = ({ data }) => {
console.log('slider in index page---', data);
...
}
export const query = graphql`
query {
homepageSlider: nacelleContent(type: { eq: "heroBanner" }, handle: { eq: "home-slider" }) {
title
remoteFields
featuredMedia {
remoteImage {
childImageSharp {
gatsbyImageData(height: 2500, placeholder: TRACED_SVG)
}
}
}
}
benefits: nacelleContent(type: { eq: "list" }, handle: { eq: "benefits" }) {
handle
title
remoteFields
}
certificates: ...
testimonial: ...
satisfacts: ...
collections: ...
}
}
If I check the console log on vercel, it says all of the data has null except collections.
But all of the data exist if I check console log on local environment.
Why does this happen? It seems like a gatsby or vercel issue.
// package.json
...
"dependencies": {
"#contentful/rich-text-from-markdown": "^15.0.0",
"#contentful/rich-text-react-renderer": "^15.0.0",
"#contentful/rich-text-types": "^15.0.0",
"#emotion/core": "^10.0.35",
"#loadable/component": "^5.14.1",
"#nacelle/client-js-sdk": "^3.1.0",
"#nacelle/gatsby-source-nacelle": "^2.10.2",
"#nacelle/react-components": "^2.10.1",
"#nacelle/react-dev-utils": "^2.10.1",
"#nacelle/react-hooks": "^2.11.2",
"#nacelle/react-recharge": "^2.11.0",
"#react-hook/media-query": "^1.1.1",
"autoprefixer": "^10.2.5",
"change-case": "^4.1.2",
"fuse.js": "^6.4.1",
"gatsby": "^2.27.0",
"gatsby-alias-imports": "^1.0.6",
"gatsby-plugin-emotion": "^4.5.0",
"gatsby-plugin-fullstory": "^3.2.0",
"gatsby-plugin-google-tagmanager": "^3.2.0",
"gatsby-plugin-image": "^1.1.2",
"gatsby-plugin-manifest": "^3.1.0",
"gatsby-plugin-postcss": "^4.1.0",
"gatsby-plugin-react-helmet": "^4.2.0",
"gatsby-plugin-scroll-reveal": "0.0.7",
"gatsby-plugin-sharp": "^2.9.0",
"gatsby-plugin-transition-link": "^1.20.5",
"gatsby-source-filesystem": "^2.6.1",
"gatsby-transformer-sharp": "^2.7.0",
"gsap": "^3.6.1",
"nuka-carousel": "^4.7.7",
"numeral": "^2.0.6",
"postcss": "^8.2.8",
"react": "^16.13.1",
"react-alice-carousel": "^2.5.1",
"react-dom": "^16.13.1",
"react-helmet": "^6.1.0"
},
"devDependencies": {
"#babel/core": "^7.11.1",
"#babel/plugin-proposal-optional-chaining": "^7.11.0",
"eslint": "^7.6.0",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"lint-staged": "^10.2.11",
"tailwindcss": "^2.0.4"
},
...
// gatsby-config.js
require('dotenv').config();
module.exports = {
plugins: [
{
resolve: '#nacelle/gatsby-source-nacelle',
options: {
nacelleSpaceId: process.env.GATSBY_NACELLE_SPACE_ID,
nacelleGraphqlToken: process.env.GATSBY_NACELLE_GRAPHQL_TOKEN,
cmsPreviewEnabled: process.env.NACELLE_PREVIEW_MODE,
contentfulPreviewSpaceId: process.env.CONTENTFUL_PREVIEW_SPACE_ID,
contentfulPreviewApiToken: process.env.CONTENTFUL_PREVIEW_API_TOKEN,
cacheDuration: 1000 * 60 * 60 * 24 // 1 day in ms
}
},
'gatsby-plugin-postcss',
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
start_url: `/`,
icon: `src/images/favicon-32.png`, // This path is relative to the root of the site.
}
},
'gatsby-transformer-sharp',
'gatsby-plugin-image',
'gatsby-plugin-emotion',
'gatsby-alias-imports',
'gatsby-plugin-react-helmet',
{
resolve: `gatsby-plugin-google-tagmanager`,
options: {
id: process.env.GOOGLE_TAG_MANAGER_ID,
includeInDevelopment: false,
},
},
`gatsby-plugin-scroll-reveal`,
// `gatsby-plugin-transition-link`
]
};
UPDATE:
Node v14.x is running on my local environment, and tried to select Node version 12 on the Vercel.
Many warning messages were disappeared, but I had no luck.
What I think that's weird is that I can see the content nodes difference between develop and build.
As you can see the images, it has created 128 content nodes while running npm run dev on the local side.
Otherwise, it has created only 100 content nodes on Vercel.
I am not sure if that is the main issue.
But basically gatsby has a rule of limitation for the content nodes?

Why does this happen? It seems like a gatsby or vercel issue.
It's hard to say with the provided details. To me, it seems that the Vercel server is facing a timeout response for some GraphQL queries/products/nodes (the warnings) so it could be a pang of shared guilt.
To debug and try to fix the issue at the same time, taking into account that the project works perfectly fine locally, I would try to match environments, starting by setting the same Node version. This will assure you that you are running the same dependency version.
Vercel allows you to configure the Node version from the backoffice or by setting a node property inside engine object in the package.json. From the docs:
Defining the node property inside engines of a package.json file
will override the selection made in the Project Settings and print a
Build Step warning if the version does not match.
In order to find out which Node.js version your Deployment is using,
run node -v in the Build Command or log the output of
process.version.
So add:
"engines": { "node": "12.x" }
Being 12.x the prompted version when running the node -v command.
Hopefully, this will fix your issue but if not, it would help you to debug better.

Related

Error: The result of this StaticQuery could not be fetched

Overview
I use the gatsby environment.
Since graphql is used in gatsby, useStaticQuery is used.
It works fine in the development environment(gatsby develop), In the environment after building(gatsby build && gatsby serve), an error like the title has occurred.
Error Text
Error: The result of this StaticQuery could not be fetched.
This is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github.com/gatsbyjs/gatsby/issues
Error code
const data = useStaticQuery(
graphql`
query {
allArticle(sort: { order: DESC, fields: updatedAt___seconds }) {
edges {
node {
category
id
thumbnail
title
createdAt {
seconds
}
}
}
}
allRanking {
edges {
node {
id
category
title
thumbnail
}
}
}
}
`
)
※ Since it worked correctly in secret mode, I wonder if something is wrong with the cache.
What I tried
Delete gatsby
$ yarn remove gatsby
$ rm -rf node_modules
$ yarn install
$ gatsby build && gatsby serve
exec gatsby clean command
$ gatsby clean
change component name and file
https://github.com/gatsbyjs/gatsby/issues/24902#issuecomment-847926225
delete .cache file
my environment
OS : MacOS
package.json
"dependencies": {
"firebase": "^8.6.7",
"gatsby": "^3.6.2",
"gatsby-plugin-advanced-sitemap": "^2.0.0",
"gatsby-plugin-clarity": "^1.0.0",
"gatsby-plugin-dark-mode": "^1.1.2",
"gatsby-plugin-google-adsense": "^1.1.3",
"gatsby-plugin-google-gtag": "^3.7.1",
"gatsby-plugin-manifest": "^3.6.0",
"gatsby-plugin-offline": "^4.6.0",
"gatsby-plugin-react-helmet": "^4.6.0",
"gatsby-plugin-twitter": "^3.12.0",
"gatsby-source-filesystem": "^3.7.1",
"react": "^17.0.1",
"react-calendar-heatmap": "^1.8.1",
"react-copy-to-clipboard": "^5.0.4",
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0",
"react-lazyload": "^3.2.0",
"react-markdown": "5.0.3",
"react-scroll": "^1.8.2",
"react-slick": "^0.28.1",
"react-syntax-highlighter": "^15.4.3",
"react-tooltip": "^4.2.21",
"remark-gfm": "^1.0.0",
"slick-carousel": "^1.8.1",
"typescript": "^4.3.2"
},
It's difficult to guess what's going on, as you pointed it seems related to cache issues, however, you've tried all the cache-related stuff. I'd suggest:
Remove gatsby-plugin-offline and add gatsby-plugin-remove-serviceworker since you won't be using service-workers anymore
Check the importation path. It should be:
import { useStaticQuery } from 'gatsby';
Check the SEO component naming and importation (i.e: Seo.js or SEO.js). The same applies for Layout

Hot module reload is not working on my nextjs app

I have a project based on nextjs. Oddly enough, the HMR is not working properly for my project. Every time I make changes I have to re run the process. I have attached details of my next config and package.json:
next.config:
const withSass = require("#zeit/next-sass");
const withCSS = require("#zeit/next-css");
module.exports = withCSS(
withSass({
webpack(config, options) {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: "url-loader",
options: {
limit: 100000,
},
},
});
return config;
}
})
);
package.json
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next export"
},
"dependencies": {
"#zeit/next-css": "^1.0.1",
"#zeit/next-sass": "^1.0.1",
"antd": "^3.26.8",
"chartjs": "^0.3.24",
"classnames": "^2.2.6",
"draft-js": "^0.11.4",
"isomorphic-unfetch": "^3.0.0",
"moment": "^2.24.0",
"next": "^9.2.1",
"node-sass": "^4.13.1",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-helmet": "^5.2.1",
"react-markdown": "^4.3.1",
"react-mde": "^8.1.0",
"react-redux": "^7.2.0",
"react-select": "^3.0.8",
"react-slick": "^0.25.2",
"react-toastify": "^5.5.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"showdown": "^1.9.1",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-react": "^7.18.3",
"url-loader": "^3.0.0"
}
I have tried removing node_modules and reinstalling again as well, doesnt seem to fix the issue.
Following is my project structure
Got help from #felixmosh. There was issue because of my folders were case was not matching route case. Fixed the issues by changing folder name to route names.
I just solved this problem by deleting folder ".next" and then closing terminal, and run npm run dev again.
Sometimes, when you accidentally name a component starting with a lowercase and then later changes to capital letter, next cache will still consider the older name and won't count it as a normal component.
The easiest solution is to copy the contents of the components, delete the file, and create one with a proper component name.
in my case hot reload didn't work because there was assetsPrefix in my next.config.js. You can remove or change them to "/" in the development mode and everything will be as expected.
For people NOT using modules and using Typescript paths.
For my setup, I just like having general .scss files
So, in my _app.tsx
I add Styles/index.scss
Then, in my index.scss
I add my #import '~Styles/flex.scss'
take note of the ~
this was required for it to work with hot reloading.
Wrt to Next js version 10+ and in addition to Pranay's answer, make sure your routes case matches the case of the folder.
Also, I noticed the component name has to start with the upper case. If your file name is dashboard.jsx, the component name should be Dashboard.
// home/dashboard.js
const Dashboard = () => {
....
}
export default Dashboard
I had to go to package.json remove react and react-dom and re add them with yarn add.
In my case, it wasn't working on Chrome. But it was working on Edge browser. And funny enough... even on a guest chrome window.
So all I had to do was...
Clear the cookies and hard refresh.
Force audit fix worked for me. Don't know the exact reason, might be some conflicts between dependencies.
Steps
1)Run this command in your next project directory.
npm audit fix --force
you need to run npm run dev instead npm run start

How to fix tsc-watch restarts when test file uploading?

I want to test file uploading API locally in my NestJS project. I have followed this doc. However, when I uploaded files the tsc-watch restart since the upload folder is changed.
Here I am using NestJS version 6 and everything installed from nest-cli. I am also using Google Cloud Storage to store the files. I test the project locally by running yarn start:dev.
I have tried adding upload folder in exclude option in both tsconfig.json and tsconfig.build.json but it does not work.
I have also tried using nodemon. Unfortunately, nodemon does not restart when I make change to the code.
Here are some codes (repo here):
controller
#Patch(':id/file')
#UseInterceptors(
FileInterceptor('file', { dest: join(__dirname, '../../upload') }),
)
async uploadProblem(
#UploadedFile() file: FileDto,
#Param('id') id: string,
) {
if (file) {
await this.service.uploadProblem(id, file);
} else {
throw new BadRequestException('No files uploaded');
}
}
service
async uploadProblem(id: string, file: FileDto) {
const problem = await this.findById(id);
await this.fileService.uploadFile(`${problem.code}/problem`, file);
}
fileService
async uploadFile(name: string, file: FileDto) {
await this.bucket.upload(file.path, {
destination: name,
contentType: file.mimetype,
resumable: false,
});
removeSync(file.path);
}
package.json
{
...
"scripts": {
...
"start:dev": "tsc-watch -p tsconfig.build.json --onSuccess \"node dist/main.js\"",
...
},
"dependencies": {
"#google-cloud/storage": "^3.3.1",
"#nestjs/common": "^6.0.0",
"#nestjs/core": "^6.0.0",
"#nestjs/mongoose": "^6.1.2",
"#nestjs/platform-express": "^6.0.0",
"class-transformer": "^0.2.3",
"class-validator": "^0.10.1",
"fs-extra": "^8.1.0",
"mongoose": "^5.7.3",
"reflect-metadata": "^0.1.12",
"rimraf": "^2.6.2",
"rxjs": "^6.3.3"
},
"devDependencies": {
"#nestjs/testing": "^6.0.0",
"#types/express": "4.16.1",
"#types/fs-extra": "^8.0.0",
"#types/jest": "24.0.11",
"#types/mongoose": "^5.5.19",
"#types/node": "11.13.4",
"#types/supertest": "2.0.7",
"jest": "24.7.1",
"prettier": "1.17.0",
"supertest": "4.0.2",
"ts-jest": "24.0.2",
"ts-node": "8.1.0",
"tsc-watch": "2.2.1",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3"
},
...
}
I expect the file to be uploaded and deleted afterward, but tsc-watch keeps restarting and never upload nor delete the file.
Is there anyway to stop tsc-watch from restart when upload directory is changed, or is there any other tools should I use?
The first solution, using ts-lint is to move the upload folder outside the src folder and ignore that folder.
Another solution is the same as you suggest, using nodemon with ts-node, but nodemon itself has the problem of watching files inside docker and change start command to the following.
"start": "nodemon -L --watch 'src/**/*.ts' --exec ts-node src/main.ts",
You can set to ignore watch in package.json
"watch": {
"ignore": "upload"
}

vue-cli3+electron+chromedriver+selenium-webdriver cannot find element

I use vue-cli project (that installed electron+seleniumWebDriver) run tests with ChromeDriver.
I keep running chromedriver (that installed in my vue-cli project) then I ran the test file 'node ff.js'.
The Electron app was run in screen but nothing happened. Then wait till the process exited, the result became error 'UnhandledPromiseRejectionWarning: WebDriverError: unknown error: DevToolsActivePort file doesn't exist'.
I searched the web for it and found the solution that the others claimed it works fine. It is just add a '--disable-dev-shm-usage' to chrome options. But it still error.
ff.js
const webdriver = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome');
const driver = new webdriver.Builder()
// The "9515" is the port opened by chrome driver.
.usingServer('http://localhost:9515')
.withCapabilities({
chromeOptions: {
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', 'start-minimized'],
// Here is the path to your Electron binary.
binary: './dist_electron/mac/myapp.app/Contents/MacOS/myapp'
}
})
.setChromeOptions(new chrome.Options().addArguments('--remote-debugging-port=7070'))
.forBrowser('electron')
.build()
driver.quit()
package.json
"devDependencies": {
"#types/chai": "^4.1.0",
"#types/mocha": "^5.2.4",
"#vue/cli-plugin-babel": "^3.5.0",
"#vue/cli-plugin-e2e-nightwatch": "^3.6.0",
"#vue/cli-plugin-eslint": "^3.5.0",
"#vue/cli-plugin-typescript": "^3.5.0",
"#vue/cli-plugin-unit-mocha": "^3.5.0",
"#vue/cli-service": "^3.5.0",
"#vue/eslint-config-standard": "^4.0.0",
"#vue/eslint-config-typescript": "^4.0.0",
"#vue/test-utils": "1.0.0-beta.29",
"babel-eslint": "^10.0.1",
"babel-plugin-istanbul": "^5.1.3",
"bootstrap": "^4.3.1",
"chai": "^4.1.2",
"chromedriver": "^73.0.0",
"copy-webpack-plugin": "^5.0.2",
"electron": "^4.0.0",
"electron-rebuild": "^1.8.4",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0",
"jquery": "^3.4.0",
"mocha": "^6.1.4",
"mochawesome": "^3.1.2",
"node-sass": "^4.9.0",
"nyc": "^14.0.0",
"popper.js": "^1.15.0",
"sass-loader": "^7.1.0",
"selenium-webdriver": "^4.0.0-alpha.1",
"ts-node": "^8.1.0",
"ts-protoc-gen": "^0.9.0",
"typescript": "^3.2.1",
"vue-cli-plugin-electron-builder": "^1.2.0",
"vue-template-compiler": "^2.5.21",
"vuex-module-decorators": "^0.9.8",
"webdriverio": "^5.8.3"
}
ps. I've tried with ChromeDriver#74.x.x, it still resulted same error.
Actually, I've tried with Selenium RobotFramework and still found the same error. I think it was something wrong with my test writing or some settings. (I'm not good in test tool.)
Just for information
mytest.robot
*** Settings ***
Library Selenium2Library
Variables vars.py
*** Test Cases ***
Foohaha
Create Webdriver Remote desired_capabilities=${binary_location} command_executor=http://localhost:9515
Log To Console ${item.get_attribute('innerHTML')}
[Teardown] Close All Browsers
P.s. The reason why not spectron is the tester I have only use the Selenium.
After I tried almost recommended testing library. I ended up with testcafe. Setting the pref app path to my distributed app's binary then set the page to open as html file in test file. The primary path was a default value.
This is how I set it up.
.testcafe-electron-rc
{
"mainWindowUrl": "app://./index.html",
"electronPath": "/Users/xxx/Documents/ProjectFolder/dist_electron/mac/my-lovely-app.app/Contents/MacOS/my-lovely-app",
"openDevTools": "true"
}
package.json
"scripts": {
...
"cafe": "testcafe \"electron:/Users/xxx/Documents/ProjectFolder/.testcafe-electron-rc\" \"/Users/xxx/Documents/ProjectFolder/tests/e2e/specs/testcafe.js\""
},
"devDependencies": {
...
"selenium-webdriver": "^4.0.0-alpha.1",
"testcafe": "^1.1.4",
"testcafe-browser-provider-electron": "0.0.8"
}
testcafe.js
import { Selector } from 'testcafe';
fixture(`Index page`)
.page('/Users/xxx/Documents/ProjectFolder/dist_electron/bundled/index.html');
test('Body > Paragraph contains "Hello World!"', async testController => {
const paragraphSelector = await new Selector('#nav > a.router-link-exact-active.router-link-active');
const txt = await new Selector('#app > div.auth-page > div > div > div > form > fieldset:nth-child(1) > input');
await testController.click(paragraphSelector)
.typeText(txt, 'Peter Parker');
// .expect(paragraphSelector.innerText).eql("Login");//.eql('Login');
});
Hope this will help someone.

error in React-Native-Vector-Icons when using for Web / Server Side rendering

I am trying to leverage React-native-vecor-icons package in a project that uses Server-Side-Rendering react deployment (SSR).
React-native-vector-icons works fine in standard web deployments as well (not just in react-native on mobile). HOwever with Server-side-rendering there is a problem.
The package author, chose to publish his library into NPM repository with ES6 syntax for modules (eg import ... }.
While web-browsers rely on transply by babel to ES5, during app build stage -- this does not help with server side deployment. Because it is the server (NodeJs) that needs to be able to understand the package syntax.
This is, I believe, why I am getting this error.
If my understanding of the problem is correct, then I need to figure out a way to get Babel to transply this offending package on the fly and to feed it into node-js at run time.
This is where I need help, simply setting various stuff at .babelrc is not helping (see below). And I do not know how to make this work without making manual changes to the React-native-vector icons code (See at the end the manual changes I that I figured out to make... to test out the theory).
The error:
c:\Users\v\home\devel\mine\ltproject\mob\rnweb\aa1a\ssr-aft\node_modules\react-native-vector-icons\Ionicons.js:6
import createIconSet from './lib/create-icon-set';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:152:10)
at Module._compile (module.js:605:28)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at Object.react-native-vector-icons/Ionicons (c:\Users\v\home\devel\mine\ltproject\mob\rnweb\aa1a\ssr-aft\build\server.js:1527:18)
The piece of code from React Native Vector Icons library within node_modules, that's causing the problem (first import statement)
/**
* Ionicons icon set component.
* Usage: <Ionicons name="icon-name" size={20} color="#4F8EF7" />
*/
import createIconSet from './lib/create-icon-set';
import glyphMap from './glyphmaps/Ionicons.json';
const iconSet = createIconSet(glyphMap, 'Ionicons', 'Ionicons.ttf');
export default iconSet;
export const Button = iconSet.Button;
export const TabBarItem = iconSet.TabBarItem;
export const TabBarItemIOS = iconSet.TabBarItemIOS;
export const ToolbarAndroid = iconSet.ToolbarAndroid;
export const getImageSource = iconSet.getImageSource;
My package.json
{
"name": "aa1a",
"version": "0.0.1",
"license": "XYZ",
"private": true,
"scripts": {
"start": "razzle start",
"build": "razzle build",
"test": "razzle test --env=jsdom",
"start:prod": "NODE_ENV=production node build/server.js",
"vclient": "webpack --watch --progress"
},
"dependencies": {
"#jaredpalmer/after": "latest",
"airbnb-browser-shims": "^2.1.0",
"bootstrap": "^3.3.7",
"bundle-loader": "^0.5.6",
"compression": "^1.7.2",
"express": "^4.16.2",
"postcss-syntax": "^0.10",
"prop-types": "^15.6.1",
"pubsub-js": "^1.6",
"qs": "^6.5.2",
"razzle": "^2.0.0-alpha.12",
"react": "^16.3.2",
"react-art": "^16.3.2",
"react-bootstrap": "^0.32.1",
"react-dom": "^16.3.2",
"react-helmet": "^5.2.0",
"react-markdown": "^3.3.2",
"react-native-vector-icons": "^4.6.0",
"react-native-web": "^0.6.1",
"react-router-dom": "^4.3.0-rc.2",
"react-virtualized": "^9.19",
"react-virtualized-image-measurer": "^0.3",
"resize-observer-polyfill": "^1.5.0",
"serialize-javascript": "^1.4.0",
"tree-model": "^1.0.6",
"webpack-visualizer-plugin": "^0.1.11"
},
"devDependencies": {
"babel-plugin-react-native-web": "^0.7.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-preset-react-native": "^4.0.0",
"babel-register": "^6.26.0",
"mini-css-extract-plugin": "^0.4.0",
"node-sass": "^4.8.3",
"sass-loader": "^6.0.7",
"stylelint": "^9.2.1",
"stylelint-config-standard": "^18.2.0",
"treeify": "^1.1.0",
"webpack-bundle-analyzer": "^2.9.1"
}
}
I had also tried to tell babel-loader to transply into ES5 syntax compatible with node version ( (I am running node 9.10)). But installing babel-preset-env #1.3.3 (because that's what razzle/babel is using)). And, then, modifying my .babelrc with
{
"presets": ["razzle/babel",
"react-native",
[
"babel-preset-env",
{
"targets": {
"node": 9,
"esmodules": true
}
}
]
],
"plugins": ["react-native-web",
"transform-es2015-modules-commonjs",
"transform-class-properties"
]
}
That, unfortunately, did not help -- getting same error.
I also tried upgrading to node v10.2 and using
npm start -- --experimental-modules
... razzle start "--experimental-modules"
Did not work either.. although I am not 100% sure if razzle, in this case is passing the command line arg into node.js
As noted, above -- I figured out the manual code changes I need to make to get RN vector icons to start up under Node JS (I am using version 9.1)
Change 1) CD to node_modules/react-native-vector-icons. Copy Ionicons.js into Ionicons_org.js.
Change 2) Replace the Ionicons.js with this code (and delete the rest).
require('babel-register')({
plugins: ["transform-class-properties","react-native-web"],
presets: [ 'env' ],
// Ignore everything in node_modules except node_modules/react-native-vector-icons
ignore: /node_modules\/(?!react-native-vector-icons)/
})
// Import the rest of our application.
module.exports = require('./Ionicons_org.js')

Resources