I get error that is 'Bigint' with #solana/web3.js on expo - expo

I do building blockchain app on expo but I encountered error 'bigint'
I did inject 'if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')' into the solana libarary. But to no avail.
I entered the code as below:
import {
clusterApiUrl,
Connection,
PublicKey,
Transaction,
} from "#solana/web3.js";
...
const connection = new Connection(clusterApiUrl("devnet"));
However I get error message soon:
ReferenceError: Can't find variable: BigInt
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/expo/build/errors/ExpoErrorManager.js:25:19 in errorHandler
at node_modules/expo/build/errors/ExpoErrorManager.js:30:24 in <anonymous>
at node_modules/#react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:237:40 in guardedLoadModule
at http://192.168.219.101:19000/index.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:null in global code
Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/expo/build/errors/ExpoErrorManager.js:25:19 in errorHandler
at node_modules/expo/build/errors/ExpoErrorManager.js:30:24 in <anonymous>
at node_modules/#react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/expo/build/errors/ExpoErrorManager.js:25:19 in errorHandler
at node_modules/expo/build/errors/ExpoErrorManager.js:30:24 in <anonymous>
How can I fix the error?
The code below is my expo environment.
package.json
"name": "my-app",
"version": "1.0.0",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"#expo-google-fonts/cabin": "^0.2.2",
"#expo-google-fonts/inter": "^0.2.2",
"#metaplex-foundation/js": "^0.18.1",
"#react-native-async-storage/async-storage": "^1.17.11",
"#react-navigation/native": "^6.1.4",
"#react-navigation/native-stack": "^6.9.10",
"#solana/web3.js": "^1.73.2",
"axios": "^1.3.3",
"bigint-buffer": "^1.1.5",
"bs58": "^5.0.0",
"expo": "~47.0.12",
"expo-application": "~5.0.1",
"expo-background-fetch": "~11.0.1",
"expo-clipboard": "~4.0.1",
"expo-font": "~11.0.1",
"expo-linear-gradient": "~12.0.1",
"expo-linking": "~3.3.0",
"expo-location": "~15.0.1",
"expo-modules-core": "~1.0.4 || ~1.1.1",
"expo-secure-store": "^12.0.0",
"expo-splash-screen": "~0.17.5",
"expo-status-bar": "~1.4.2",
"metro-config": "^0.75.0",
"react": "18.1.0",
"react-native": "0.70.5",
"react-native-get-random-values": "^1.8.0",
"react-native-logs": "^5.0.1",
"react-native-maps": "1.3.2",
"react-native-radial-slider": "^0.0.4",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^4.5.0",
"react-native-svg": "13.4.0",
"react-native-url-polyfill": "^1.3.0",
"tweetnacl": "^1.0.3"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#types/react": "~18.0.24",
"#types/react-native": "~0.70.6",
"typescript": "^4.6.3"
},
"private": true
I tried rebuilding but to no avail.

Related

AWS-Amplify DataStoreStateError: Tried to execute DataStore.query() while DataStore was "Stopping"

JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Categories
api
Environment information
Details
Describe the bug
DataStoreStateError: Tried to execute DataStore.query() while DataStore was "Stopping".
This can only be done while DataStore is "Started" or "Stopped". To remedy:
Ensure all calls to stop() and clear() have completed first.
If this is not poss...
Hi, I have an amplify project to host backend for react-native mobile app. Suddenly it stopped to work. Any call to the data store will receive the message i mentioned above.
Our work plan is to provide amplify backend as an NPM package. This package is used from app developer to make calls to AWS-Amplify. Since 6 months everything works fine until 4 days go. We didn't had breaking changes or something. Just added a few lambda function which i don't think it could cause this issue.
We are starting datastore when app is open. DataStore.start() and clear it on SignIng event and SignOut event. We didn't make any change in this flow since a long time (4 months).
We tried to reproduce the issue locally but it is not possible for somehow. Since we are using typescript to write our NPM package. We test functionality locally with node or tsx where everything works, then we publish it and downloaded in another project react-native where everything works good. Once it is deployed, no action from DataStore could be executed. The app crashed and Sentry show us the message above. And again that start to happen 4 days ago until now.
Expected behavior
To be able to execute DataStore manipulation functionality (query, save, delete... etc) / Get connection with data store.
Reproduction steps
Whenever we call datastore functions in the react-native app. It will show this message:
DataStoreStateError: Tried to execute DataStore.query() while DataStore was "Stopping".
This can only be done while DataStore is "Started" or "Stopped". To remedy:
Ensure all calls to stop() and clear() have completed first.
If this is not poss...
Code Snippet
// Put your code below this line.
// where i clear data store and start it, just using auth events
// Clear the local datastore when signing out.
// As advised in: https://docs.amplify.aws/lib/datastore/sync/q/platform/js/#clear-local-data
EventHandler.OnSignOut = async () => {
if (Application.hasBooted()) {
await Application.clear();
}
};
// Clear the local datastore when signing in.
// As advised in: https://docs.amplify.aws/lib/datastore/sync/q/platform/js/#clear-local-data
EventHandler.OnSignIn = async () => {
if (Application.hasBooted()) {
await Application.clear();
}
};
// Boot the application as soon as the DataSync is completed
// Check if it has not been booted already first
EventHandler.OnDataSynced = async () => {
if (!Application.hasBooted()) {
await Application.boot();
}
};
// Where i do datastore call
/**
* #name SaveAccount
* #description: Save or update an account.
* If the account already exists in the datastore based
* on its id, it is updates. Otherwise a
* #type {Function}
* #param {AccountDetails} accountDetails
* #param {AccountAttributes} params
* #returns {Promise<AccountDetails>}
*/
const SaveAccount = async (
accountDetails: AccountDetails,
params?: AccountAttributes,
): Promise<AccountDetails> => {
const current = await GetAccountDetails(accountDetails.id);
if (current instanceof AccountDetails) {
return await DataStore.save(
AccountDetails.copyOf(
current,
updated => {
if (params) {
for (const key in params) {
updated[key] = params[key];
}
}
},
),
);
}
accountDetails = accountDetails instanceof AccountDetails
? accountDetails
: new AccountDetails(accountDetails);
return await DataStore.save(accountDetails);
};
aws-exports.js
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "",
"aws_cognito_identity_pool_id": "",
"aws_cognito_region": "",
"aws_user_pools_id": "",
"aws_user_pools_web_client_id": "",
"oauth": {},
"aws_cognito_username_attributes": [
"EMAIL"
],
"aws_cognito_social_providers": [],
"aws_cognito_signup_attributes": [],
"aws_cognito_mfa_configuration": "OFF",
"aws_cognito_mfa_types": [
"SMS"
],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": [
"REQUIRES_LOWERCASE",
"REQUIRES_NUMBERS",
"REQUIRES_UPPERCASE"
]
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
],
"aws_appsync_graphqlEndpoint": "*****",
"aws_appsync_region": "",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "",
"aws_user_files_s3_bucket": "",
"aws_user_files_s3_bucket_region": "*"
};
package.json
{
"name": "#financiallease/react-native-amplify",
"version": "7.1.0",
"description": "",
"author": "itsupport#financiallease.nl",
"main": "dist/financiallease.js",
"module": "dist/financiallease.js",
"browser": "dist/financiallease.js",
"typings": "dist/financiallease.d.ts",
"types": "dist/financiallease.d.ts",
"license": "LGPL",
"scripts": {
"__BUNDLING": null,
"build:clean": "rimraf dist/",
"build": "npm run build:clean && rollup -c",
"bundle-local": "npm run build && npm pack && mv -v financiallease-react-native-amplify-*.tgz /usr/local/npm/#financiallease/react-native-amplify.tgz",
"__LINTING": null,
"autoformat": "npm run lint-typescript -- --fix && npm run lint-nodejs -- --fix",
"lint-nodejs": "eslint --config amplify/.eslintrc.js 'amplify/backend/function/**/index.js'",
"lint-typescript": "eslint --config .eslintrc.js '{src,test}/**/*.ts'",
"lint": "npm run lint-typescript && npm run lint-nodejs",
"coverage": "jest -c jest.config.ts --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false",
"test": "jest -c jest.config.ts",
"__DOC GENERATION": null,
"docs:generate": "npm run build:clean && sed '/[[_TOC_]]/d' README.md > README.sanitized.md && typedoc --readme README.sanitized.md --entryPoints src --entryPointStrategy expand --out docs --theme hierarchy --name \"React Native Amplify - docs\" --includeVersion",
"docs:serve": "node -r esm --inspect docker/server.js",
"__AMPLIFY BACKEND": null,
"amplify-modelgen": "node amplify/scripts/amplify-modelgen.js",
"amplify-push": "node amplify/scripts/amplify-push.js",
"scan": "npm run build && npm run lint && npm run test && npm run docs:generate",
"upgrade-amplify-deps": "npx npm-check-updates -i '/(#?aws-amplify|#react-native-community/netinfo)/' && npm update"
},
"publishConfig": {
"#financiallease:registry": "https://gitlab.com/api/v4/projects/35071033/packages/npm/"
},
"dependencies": {
"#algolia/client-search": "^4.14.2",
"#algolia/transporter": "^4.14.2",
"#aws-amplify/core": "^4.7.2",
"#aws-amplify/datastore": "^3.12.8",
"#react-native-async-storage/async-storage": "^1.17.4",
"#react-native-community/netinfo": "^9.3.0",
"#types/amplify": "^1.1.25",
"aws-amplify": "^4.3.33",
"aws-amplify-react-native": "^6.0.5",
"aws-sdk": "^2.1142.0",
"deep-equal": "^2.0.5"
},
"devDependencies": {
"#aws-amplify/cli-extensibility-helper": "^2.3.33",
"#babel/core": "^7.17.9",
"#babel/preset-env": "^7.16.11",
"#babel/preset-typescript": "^7.16.7",
"#rollup/plugin-alias": "^3.1.9",
"#rollup/plugin-babel": "^5.3.1",
"#rollup/plugin-commonjs": "^21.0.3",
"#rollup/plugin-json": "^4.1.0",
"#rollup/plugin-multi-entry": "^4.1.0",
"#rollup/plugin-node-resolve": "^13.1.3",
"#rollup/plugin-typescript": "^8.3.1",
"#types/jest": "^27.4.1",
"#types/jest-when": "^3.5.2",
"#types/node": "^17.0.30",
"#typescript-eslint/eslint-plugin": "^5.35.1",
"#typescript-eslint/parser": "^5.18.0",
"aws-sdk-mock": "^5.7.0",
"babel-jest": "^28.0.3",
"babel-plugin-module-resolver": "^4.1.0",
"base64-js": "^1.5.1",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-jsdoc": "^39.2.9",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-sort-exports": "^0.6.0",
"esm": "^3.2.25",
"fetch-mock": "^9.11.0",
"isomorphic-unfetch": "^3.1.0",
"jest": "^27.5.1",
"jest-junit": "^13.2.0",
"jest-when": "^3.5.1",
"jsdoc": "^3.6.10",
"mustache": "^4.2.0",
"nodemon": "^2.0.16",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"rollup": "^2.70.1",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-flat-dts": "^1.7.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-ts": "^3.0.2",
"ts-node": "^10.7.0",
"tsconfig-paths": "^3.14.1",
"tslib": "^2.3.1",
"typedoc": "^0.22.15",
"typedoc-theme-hierarchy": "^1.1.1",
"typescript": "^4.6.3",
"uuid": "^8.3.2"
}
}
Logs from Sentry
This change was introduced in this PR to explicitly handle internal race conditions between overlapping clears/stops and starts/queries/mutations. Previously, DataStore consumers would see random, erratic transaction/locking/corruption errors that were uninstructive, difficult to recover from, or silent. This change raises the conflicts so consuming code can be aware of and handle those conflicts.
With that said, you just need to ensure DataStore.clear() resolves first, after making sure the query you're trying to run should be on the post-clear() side of that boundary! This could be as simple as a retry loop or a flag — or even using the clear() promise as your "flag".
Initialize your flag:
let onReady = Promise.resolve();
let isReady = true;
When you need to clear:
let onReady = DataStore.clear();
isReady = false;
onReady.then(() => isReady = true);
Then, for operations that should operate once the clear is complete:
async getResults() {
await onReady;
return DataStore.query(...);
}
And for those that should be canceled (no longer make sense) if they interrupt a clear, something like:
async getResults() {
if (isReady) {
return DataStore.query(...);
} else {
throw new Error(
"Sorry. We're still clearing data. Try again shortly."
);
}
}
I've provided a little more detail in the cross-post of this question on GitHub.

Module parse failed: Unexpected character '�' After updating to angular 12

After upgrading Angular from v.11 to v.12 I am getting the following Error
home.Component.ts
imgname= require("../assets/images/imgname.png");
./src/assets/images/imgname.png:1:0 - Error: Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
"devDependencies": {
"#angular-devkit/build-angular": "^12.0.1",
"#angular/cli": "~12.0.1",
"#angular/compiler-cli": "~12.0.1",
"#angular/language-service": "~12.0.1",
"#types/jasmine": "~3.7.4",
"#types/jasminewd2": "~2.0.9",
"#types/node": "^15.6.1",
"css-loader": "5.2.6",
"html-webpack-plugin": "^5.3.1",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.6.0",
"mini-css-extract-plugin": "~1.6.0",
"protractor": "~7.0.0",
"ts-loader": "9.2.2",
"ts-node": "~10.0.0",
"tslint": "~6.1.0",
"typescript": "~4.2.4"
"webpack": "~5.37.1",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.7.0"
}
angular.json
"assets": [
"src/favicon.ico",
"src/assets",
]
Unfortunately I cannot answer but may have some more information. I seem to be having a similar issue though on upgrading to Angular v12. I believe in my case it relates to executing the following in my Angular.json. In my case the lines are trying to copy assets for the use of Leaflet within angular and its is no longer able to copy the .png assets.
...
"assets": [
{
"glob": "**/*",
"input": "./node_modules/leaflet/dist/images",
"output": "/assets/leaflet/"
}
],
...
Thanks
I was able to solve this issue by adding file-loader! prefix before the path:
imgname = require("file-loader!../assets/images/imgname.png");
Also, you can try another approach described in this answer https://stackoverflow.com/a/67932447/8171860

Unexpected token error when migrating to native classes for components

I upgraded to Ember 3.11 and I want to start using native classes for my components.
When I change a component class to something similar like:
export default class MyClassName extends BaseComponent {
myFieldName;
}
I get a build error
"Parsing error: Unexpected token ;" because of the class field.
Ideas how to make sure ember-cli doesn't complain about the new syntax are more than welcome.
Thanks
UPDATE:
Following jelhan's suggestion below I updated my package.json file as in ember-cli/ember-new-output (https://github.com/ember-cli/ember-new-output/blob/master/package.json). This didn’t help. I also created a brand new ember project with a single component in it and I still have the same problem.
This is the package.json file which gets generated when creating new ember project (ember-cli 3.11.0):
{
"name": "my-project",
"version": "0.0.0",
"private": true,
"description": "Small description for my-project goes here",
"repository": "",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"start": "ember serve",
"test": "ember test"
},
"devDependencies": {
"#ember/jquery": "^0.6.0",
"#ember/optional-features": "^0.7.0",
"broccoli-asset-rev": "^3.0.0",
"ember-ajax": "^5.0.0",
"ember-cli": "~3.11.0",
"ember-cli-app-version": "^3.2.0",
"ember-cli-babel": "^7.7.3",
"ember-cli-dependency-checker": "^3.1.0",
"ember-cli-eslint": "^5.1.0",
"ember-cli-htmlbars": "^3.0.1",
"ember-cli-htmlbars-inline-precompile": "^2.1.0",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.11.0",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^2.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.11.1",
"ember-welcome-page": "^4.0.0",
"eslint-plugin-ember": "^6.2.0",
"eslint-plugin-node": "^9.0.1",
"loader.js": "^4.7.0",
"qunit-dom": "^0.8.4"
},
"engines": {
"node": "8.* || >= 10.*"
}
}
Seems like the new syntax works fine. The javascript code executes as expected. I guess the errors I see in the build output are eslint errors only. I need to figure out how to configure eslint to understand the new syntax.
as #Lux pointed out in a comment, the value is missing.
This will fix your syntax error:
export default class MyClassName extends BaseComponent {
myFieldName = undefined;
}
Also, be sure to have the latest version of ember-cli-babel installed to ensure that you have the latest bundled set of babel plugins -- earlier versions of ember-cli-babel did not support classes. The latest at the time of writing this is 7.10.0 https://www.npmjs.com/package/ember-cli-babel
In classic syntax, this would be the equivalent of:
export default BaseComponent.extend({
myFieldName: undefined,
});
If you're curious about more of the differences -- here is a bit more information on native javascript classes in Ember from the ember-decorators documentation: https://ember-decorators.github.io/ember-decorators/docs/native-class-basics
On a somewhat related note:
I know it's been common in Ember to define all the properties a component may receive at the top to declare its API, but now is actually a really good time to get in to TypeScript, so that you may add more semantic meaning to your classes.
Initializing a property as undefined is the same as not specifying it, so with TypeScript, you can attain better semantics with:
interface Args {
myFieldName: string;
}
export default class MyClassName extends BaseComponent<Args> {
}
Assuming BaseComponent is a Glimmer Component, info here: https://octane-guides-preview.emberjs.com/release/upgrading/editions/#toc_tracked-properties
(EmberComponents don't accept Type Arguments, as far as I know)

The Broccoli Plugin: [UglifyWriter] failed with

I've had this error for 2 weeks now while trying to build an ember app in production. Building it in dev environment works fine. I also realized that disabling minifyJs in ember-cli-build prevents the error but then, the app gets stuck at loading in the browser, and in the console, I see another error: "could not import ember-resolver".
My guess is that this is as a result of the UglifyWriter not understanding some code somewhere.
The full error is:
Build failed.
File: assets/vendor.js (95443:4)
The Broccoli Plugin: [UglifyWriter] failed with:
Error
at new JS_Parse_Error (eval at (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), :1545:18)
at js_error (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:1553:11)
at croak (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2092:9)
at token_error (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2100:9)
at unexpected (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2106:9)
at semicolon (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2126:56)
at simple_statement (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2317:73)
at eval (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2186:19)
at eval (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2139:24)
at block_ (eval at <anonymous> (/home/larisoft/frontend/node_modules/uglify-js/tools/node.js:1:1), <anonymous>:2432:20)
The broccoli plugin was instantiated at:
at UglifyWriter.Plugin (/home/larisoft/frontend/node_modules/broccoli-plugin/index.js:7:31)
at new UglifyWriter (/home/larisoft/frontend/node_modules/broccoli-uglify-sourcemap/index.js:25:10)
at UglifyWriter (/home/larisoft/frontend/node_modules/broccoli-uglify-sourcemap/index.js:20:12)
at Class.postprocessTree (/home/larisoft/frontend/node_modules/ember-cli-uglify/index.js:15:50)
at /usr/local/lib/node_modules/ember-cli/lib/broccoli/ember-app.js:543:27
at Array.forEach (native)
at EmberApp.addonPostprocessTree (/usr/local/lib/node_modules/ember-cli/lib/broccoli/ember-app.js:541:23)
at EmberApp.toTree (/usr/local/lib/node_modules/ember-cli/lib/broccoli/ember-app.js:1667:15)
at module.exports (/home/larisoft/frontend/ember-cli-build.js:37:16)
at Class.setupBroccoliBuilder (/usr/local/lib/node_modules/ember-cli/lib/models/builder.js:70:19)
my package.json
{
"name": "hospitalrun",
"version": "0.9.12",
"description": "Ember front end for HospitalRun",
"homepage": "http://curacel.co",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "./script/build",
"start": "./script/server",
"test": "snyk test && ./script/test"
},
"repository": {
"type": "git",
"url": "git#github.com:HospitalRun/hospitalrun-frontend"
},
"engines": {
"node": ">= 0.10.0"
},
"author": "John Kleinschmidt",
"contributors": [
"Joel Worrall",
"Joel Glovier"
],
"license": "GPL-3.0",
"devDependencies": {
"body-parser": "^1.14.2",
"broccoli-asset-rev": "^2.4.1",
"broccoli-export-text": "0.0.2",
"broccoli-funnel": "^1.0.1",
"broccoli-manifest": "0.0.7",
"broccoli-merge-trees": "^1.0.0",
"broccoli-serviceworker": "0.1.0",
"ember-ajax": "2.3.2",
"ember-cli": "^2.4.1",
"ember-cli-active-link-wrapper": "0.2.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-content-security-policy": "0.5.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-deprecation-workflow": "0.2.2",
"ember-cli-fake-server": "0.3.1",
"ember-cli-htmlbars": "^1.0.7",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-qunit": "^2.0.0",
"ember-cli-release": "1.0.0-beta.1",
"ember-cli-sass": "^5.2.1",
"ember-cli-scss-lint": "1.0.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.4.0",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.4",
"ember-font-awesome": "2.1.1",
"ember-i18n": "4.2.1",
"ember-load-initializers": "^0.5.0",
"ember-pouch": "^3.1.0",
"ember-rapid-forms": "1.0.0-beta4",
"ember-resolver": "^2.0.3",
"ember-select-list": "0.9.5",
"ember-simple-auth": "^1.1.0-beta.3",
"ember-simple-auth-registration": "1.0.2",
"ember-suave": "2.0.1",
"ember-truth-helpers": "1.2.0",
"ember-validations": "2.0.0-alpha.4",
"express": "^4.8.5",
"glob": "^7.0.0",
"hospitalrun-dblisteners": "0.9.2",
"hospitalrun-server-routes": "0.9.7",
"loader.js": "^4.0.7",
"nano": "6.2.0",
"request": "2.72.0"
},
"dependencies": {
"ember-cli-babel": "^5.1.5",
"ember-cli-uglify": "^1.2.0",
"ember-radio-buttons": "^4.0.1",
"ember-resolver": "^2.1.0",
"snyk": "^1.14.1",
"sw-toolbox": "^3.1.1",
"uglify-js": "^2.7.4"
},
"ember-addon": {
"paths": [
"lib/pouch-fixtures"
]
}
}
My ember-cli-build:
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
// Add options here
});
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
app.import('vendor/pouchdb-list/pouchdb-list.js');
app.import('bower_components/node-uuid/uuid.js');
app.import('bower_components/bootstrap/dist/js/bootstrap.js');
app.import('bower_components/JsBarcode/CODE128.js');
app.import('bower_components/JsBarcode/JsBarcode.js');
app.import('vendor/dymo/DYMO.Label.Framework.1.2.6.js');
app.import('bower_components/moment/moment.js');
app.import('bower_components/typeahead.js/dist/typeahead.bundle.js');
app.import('bower_components/pikaday/pikaday.js');
app.import('bower_components/filer.js/src/filer.js');
app.import('bower_components/idb.filesystem/src/idb.filesystem.js');
app.import('bower_components/pikaday/css/pikaday.css');
app.import('vendor/octicons/octicons/octicons.css');
app.import('bower_components/pouchdb-load/dist/pouchdb.load.js');
app.import('bower_components/pouchdb/dist/pouchdb.memory.js');
return app.toTree();
};
It seems like uglify.js has some problems with ES6 files: https://forum.ionicframework.com/t/uglifyjs-fails-with-js-parse-error-error-but-no-stack-trace/66094. In my case it was enough to downgrade one library (fold-to-ascii) to an ES5 version.
Unfortunately, an error message isn't very helpful, so finding the problematic file is unnecessarily difficult. It's hard to tell which file causes the error in Your case, but I can at least say what helped me.
I manually put a log (with help from http://discuss.emberjs.com/t/debugging-failures-in-uglifyjs/7390/6):
function js_error(message, filename, line, col, pos) {
console.log(`message: ${message} / filename: ${filename} / line: ${line}`);
throw new JS_Parse_Error(message, filename, line, col, pos);
};
into js_error function of node_modules/uglify-js/lib/parse.js (line 205 in my case), and got a message that was actually helpful:
message: SyntaxError: Unexpected token: name (ASCIIFolder) / file: 0 / line: 64911 / position: 2070881
Then, with the find in path search on text "ASCIIFolder", I was able to locate the problematic files.
Also it may be necessary to do 'clean' install of npm and bower packages (https://emberigniter.com/update-latest-ember-data-cli/):
npm cache clean && bower cache clean
rm -rf node_modules bower_components dist tmp
npm install
bower install
Alternatively You can completely disable minifying of vendor.js with [https://ember-cli.com/asset-compilation#exclude-from-minification] (although it's not the greatest solution):
// ember-cli-build.js
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
minifyJS: {
options: {
exclude: ["**/vendor.js"]
}
}
});
//...
return app.toTree();
};
which tells broccoli-uglify-sourcemap to ignore vendor.js and, therefore, should prevent an error from happening.
UPDATE:
If you are not supporting IE9 browsers then you can use ember-cli-uglify#2.0.0 stable release for minification.
uglifyjs has problem in minifying the newer ES features, you can use ember-cli-babili to minify the javascript babili in Ember-CLI.
npm uninstall --save-dev ember-cli-uglify
npm install --save-dev ember-cli-babili
I am using it my app. It's mentioned by RWJBlue in his blog(http://rwjblue.com/2017/04/21/ember-cli-targets/)
I was tired of such errors, so I replaced uglify-js with upglify-es.
Using yarn and ember-cli:
yarn upgrade ember-cli-uglify#2.0.0-beta.1
In my case I got:
Build Error (UglifyWriter)
Unexpected token: eof (undefined)
The solution was to update ember-cli-moment-shim to version v3.8.0

ember build fails, no such file or directory lstat ...funnel-input_base_path-XXX.tmp/0//index.html

The file it tries to find doesn't exist and neither does the
funnel-input_base_path-XXX.tmp folder.
It's no use to create one manually as the XXX part is randomly generated.
[folatt#ArkOS_Dev genesis]$ ember build
(node:22373) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
WARNING: Node v6.2.1 has currently not been tested against Ember CLI and may result in unexpected behaviour.
version: 1.13.13
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
Build failed.
ENOENT: no such file or directory, lstat '/home/folatt/workspace/arkos/genesis/tmp/funnel-input_base_path-mFnZOm63.tmp/0//index.html'
Error: ENOENT: no such file or directory, lstat '/home/folatt/workspace/arkos/genesis/tmp/funnel-input_base_path-mFnZOm63.tmp/0//index.html'
at Error (native)
at Object.fs.lstatSync (fs.js:976:18)
at symlink (/home/folatt/workspace/arkos/genesis/node_modules/symlink-or-copy/index.js:60:26)
at Function.symlinkOrCopySync [as sync] (/home/folatt/workspace/arkos/genesis/node_modules/symlink-or-copy/index.js:55:5)
at Funnel._copy (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/node_modules/broccoli-funnel/index.js:398:19)
at Funnel.processFile (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/node_modules/broccoli-funnel/index.js:381:8)
at Funnel.applyPatch [as _applyPatch] (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/node_modules/broccoli-funnel/index.js:298:12)
at Funnel.<anonymous> (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/node_modules/broccoli-funnel/index.js:250:10)
at Array.forEach (native)
at Funnel.processFilters (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/node_modules/broccoli-funnel/index.js:249:9)
ember-cli-build.js
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var Funnel = require('broccoli-funnel');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
'ember-cli-selectize': {
'theme': 'bootstrap3'
}
});
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
app.import('bower_components/moment/moment.js');
app.import('bower_components/lightbox2/src/js/lightbox.js');
app.import('bower_components/lightbox2/src/css/lightbox.css');
app.import('bower_components/multiselect/js/jquery.multi-select.js');
app.import('bower_components/multiselect/css/multi-select.css');
app.import("bower_components/codemirror/lib/codemirror.css");
app.import("bower_components/codemirror/lib/codemirror.js");
app.import("bower_components/codemirror/mode/css/css.js");
app.import("bower_components/codemirror/mode/htmlmixed/htmlmixed.js");
app.import("bower_components/codemirror/mode/javascript/javascript.js");
app.import("bower_components/codemirror/mode/markdown/markdown.js");
app.import("bower_components/codemirror/mode/php/php.js");
app.import("bower_components/codemirror/mode/python/python.js");
app.import("bower_components/codemirror/mode/ruby/ruby.js");
app.import("bower_components/codemirror/mode/shell/shell.js");
app.import("bower_components/codemirror/mode/xml/xml.js");
app.import("bower_components/font-awesome/css/font-awesome.css");
app.import("bower_components/fira/fira.css");
var fontAwesome = new Funnel('bower_components/font-awesome/fonts', {
srcDir: '/',
destDir: 'fonts'
});
var firaEot = new Funnel('bower_components/fira/eot', {
srcDir: '/',
destDir: 'assets/eot'
});
var firaOtf = new Funnel('bower_components/fira/otf', {
srcDir: '/',
destDir: 'assets/otf'
});
var firaTtf = new Funnel('bower_components/fira/ttf', {
srcDir: '/',
destDir: 'assets/ttf'
});
var firaWoff = new Funnel('bower_components/fira/woff', {
srcDir: '/',
destDir: 'assets/woff'
});
app.import("bower_components/lightbox2/src/images/close.png", {destDir: '/img'});
app.import("bower_components/lightbox2/src/images/next.png", {destDir: '/img'});
app.import("bower_components/lightbox2/src/images/prev.png", {destDir: '/img'});
app.import("bower_components/lightbox2/src/images/loading.gif", {destDir: '/img'});
app.import("bower_components/multiselect/img/switch.png", {destDir: '/img'});
app.import('bower_components/bootstrap/dist/js/bootstrap.js');
app.import('bower_components/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/css/bootstrap.css.map', {
destDir: 'assets'
});
app.import('bower_components/bootstrap-contextmenu/bootstrap-contextmenu.js');
return app.toTree([fontAwesome, firaEot, firaOtf, firaTtf, firaWoff]);
};
package.json
{
"name": "genesis",
"version": "0.7.1-3",
"description": "Web management frontend for arkOS servers",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember test"
},
"repository": "",
"engines": {
"node": ">= 0.10.0"
},
"author": "arkOS",
"license": "GPLv3",
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"broccoli-funnel": "^0.2.8",
"ember-cli": "1.13.13",
"ember-cli-app-version": "^1.0.0",
"ember-cli-babel": "^5.1.5",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "^1.1.0",
"ember-cli-ember-uploader": "0.0.1",
"ember-cli-htmlbars": "^1.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-ic-ajax": "0.2.4",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-qunit": "^1.0.4",
"ember-cli-release": "0.2.8",
"ember-cli-selectize": "0.4.3",
"ember-cli-simple-auth": "0.8.0",
"ember-cli-simple-auth-token": "0.7.3",
"ember-cli-sri": "^1.2.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "1.13.15",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.4"
}
}
As a side issue, why am I warned about watchman if it's an OS X program if I understand correctly and I'm using Arch Linux? [Solved]
As another side issue is the "re-evaluating native module sources is not supported" message. graceful-fs module isn't being used and installing it (to the latest version) does not make the warning message go away.
I eventually went for upgrading all devDependencies, including ember.
I run into many deprecation problems, but at least I got out of this one.