ERROR:Module not found: Error: Can't resolve 'fs' in ***/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build - angular9

I am trying to migrate my angular 8 code to angular 9.
I am seeing below errors when I started the server.
The update went fine. Please give some suggestions on this error.
Thank you in advance!!
ERROR in /Users/ert/Documents/file/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build/pdf.js
Module not found: Error: Can't resolve 'fs' in '/Users/ert/Documents/file/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build'
ERROR in /Users/ert/Documents/file/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build/pdf.js
Module not found: Error: Can't resolve 'http' in '/Users/ert/Documents/file/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build'
ERROR in /Users/ert/Documents/file/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build/pdf.js
Module not found: Error: Can't resolve 'https' in '/Users/ert/Documents/file/node_modules/ng2-pdf-viewer/__ivy_ngcc__/node_modules/pdfjs-dist/build'

I had same issue while adding PDF Js library in Angular 8 project. You can add below code in package.json it will fix the error.
{
"scripts": { },
"dependencies": { },
"devDependencies": { },
"browser": {
"fs": false
}
}

Related

JetBrains WebStorm Jest encountered an unexpected token

I have a problem with running a simple project in WebStorm IDE. This is what I get when I hit run:
Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/home/patryk/WebstormProjects/Case Converter/node_modules/hs-test-web/hstest/stage/stageTest.js:12
runner = new PureJsApplicationRunner();
^
SyntaxError: Unexpected token =
at ScriptTransformer._transformAndBuildScript (node_modules/jest/node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/hs-test-web/hstest/index.js:1:110)
At this moment, my project contains just 1 html file. I tried reinstalling nodejs and npm, but that didn't work
Good time of day,
I've encoutered the same problem with one Edu project in WebStorm IDE - when i pressed the "check" button for task - i've got issue:
"test suite failed to run
Jest encountered an unexpected token ..."
How it was solved:
Please check if nodejs and npm installed - At IDE: File\Settings, section: Languages & frameworks > nodejs and npm section > at field: "Node interpreter" you'll find something like : "node /usr/bin/node" and at field: "Package manager" the value "npm /usr/share/npm"
In IDE - you need to expand "Project pane" and to choose view mode "Project Files" - then you need open the file "package.json",
initially this file contains the code:
{
"devDependencies": {
"#types/jest": "^23.3.12",
"hs-test-web": "https://github.com/hyperskill/hs-test-web/archive/release.tar.gz",
"jest": "^27.3.1",
"puppeteer": ">=8.0.0"
},
"scripts": {
"test": "jest"
}
}
You need to add the section for "jest" - please found the complete package.json below
{
"devDependencies": {
"#types/jest": "^23.3.12",
"hs-test-web": "https://github.com/hyperskill/hs-test-web/archive/release.tar.gz",
"jest": "^27.3.1",
"puppeteer": ">=8.0.0"
},
"scripts": {
"test": "jest"
},
"jest": {
"verbose": true,
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"transformIgnorePatterns": ["/node_modules/(?!lodash-es)"],
"testRegex": "test/.*\\.spec\\.ts$"
}
}
So,i hope it help you.

Error packaging SharePoint App with gulp, 'package-solution' sub task

I am having an issue packaging a SharePoint App. Based on the documentation, we need to run:
npm install
gulp bundle --ship
gulp package-solution --ship
On the last statement: gulp package-solution --ship I get the following error:
Error - 'package-solution' sub task errored after 42 ms
Cannot read property 'name' of undefined
'package-solution' errored after 50 ms
This issue was a missing section in the file package-solution.json.
There need to be a developer section, see below:
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "my-sample-solution",
"id": "fafafafa-1776-0911-bead-abbadabba123",
"version": "2.0.0.0",
"isDomainIsolated": false,
"includeClientSideAssets": true,
"developer": {
"name": "your-company",
"websiteUrl": "http://your-company.com",
"mpnId": "",
"termsOfUseUrl": "http://your-company.com/home/about#terms",
"privacyUrl": "http://your-company.com/home/about#privacy"
}
},
"paths": {
"zippedPackage": "solution/my-sample-solution.spapp"
}
}
The solution was found in the thread related to this GitHub issue: SharePoint repository issue #6144

facing the below issue while setting thoughput in packer json file, need help to resolve this issue

Error:
Template validation failed. Errors are shown below.
Errors validating build 'amazon-ebs'. 1 error(s) occurred:
unknown configuration key: "launch_block_device_mappings[0].throughput"
script returned exit code 1
Code:
"launch_block_device_mappings": [
{
"device_name": "/dev/sda1",
"volume_size": 40,
"volume_type": "gp2",
"volume_size": 80,
"volume_type": "gp3",
"throughput": 270,
"delete_on_termination": true"
I had this issue too and I updated my packer version to 1.6.6 and that worked.

Cannot read property 'runCLI' of undefined in gulp-jest

I am trying to run jest tests with gulp using gulp-jest.
Installed these packages from npm:
"gulp-jest": "^4.0.3",
"jest-cli": "^25.3.0"
and provided the following configuration to jest:
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.js"
],
"collectCoverage": true,
"coverageDirectory": "./test/unit-test-coverage",
"coverageReporters": [
"text",
"lcov"
]
}
I have written a basic method in my gulpfile.js, referred this link:
function runJsTests() {
process.env.NODE_ENV = 'test';
const __dirname = "Features/Components";
return gulp.src(__dirname).pipe(jest({
}));
}
However, I am getting the following error when I run the gulp task:
TypeError: Cannot read property 'runCLI' of undefined
I had the same trouble last friday, to resolve it, I finally had to downgrade version used of jest-cli :
"#types/jest": "24.9.0",
"jest": "24.9.0",
"ts-jest": "24.3.0
"jest-cli": "24.9.0",
"jest-html-reporter": "2.5.0",
A bug known on new version of Jest-cli
-> think to remove all node_modules and package_lock.json!
Good luck ;)

Cannot create JHipster application (error in ng plugin)

I appreciate this is probably not a JHipster specific issue, but how some of my dependencies may be installed. It happens on 3.0.0 and 3.1.0. On the other hand 2.27.0 is fine.
This happens when I run yo jhipster.
...
Server app generated successfully.
Client app generated successfully.
(node:38364) 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.
[21:00:11] Using gulpfile ~/dev/projects/blog/gulpfile.js
[21:00:11] Starting 'install'...
[21:00:11] Starting 'wiredep:test'...
[21:00:11] Starting 'wiredep:app'...
[21:00:11] Starting 'ngconstant:dev'...
[21:00:11] 'ngconstant:dev' errored after 12 ms
[21:00:11] Error in plugin 'gulp-tslint-log'
TypeError: Path must be a string. Received null
at assertPath (path.js:7:11)
at Object.dirname (path.js:1324:5)
at getFilePath (/Users/me/dev/projects/blog/node_modules/gulp-ng-constant-fork/index.js:95:27)
at DestroyableTransform.objectStream [as _transform] (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/index.js:60:25)
at DestroyableTransform.Transform._read (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at DestroyableTransform.Writable.end (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/node_modules/readable-stream/lib/_stream_writable.js:352:10)
at ngConstantPlugin (/Users/alberto/dev/projects/blog/node_modules/gulp-ng-constant-fork/index.js:33:16)
at Gulp.<anonymous> (/Users/alberto/dev/projects/blog/gulpfile.js:164:12)
at module.exports (/Users/alberto/dev/projects/blog/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/alberto/dev/projects/blog/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/alberto/dev/projects/blog/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/alberto/dev/projects/blog/node_modules/orchestrator/index.js:134:8)
Then when I start the application I get this on the browser's console:
Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to:
Error: [$injector:nomod] Module 'blogApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.2/$injector/nomod?p0=badgeritoApp
at http://127.0.0.1:8080/bower_components/angular/angular.js:68:12
at http://127.0.0.1:8080/bower_components/angular/angular.js:2034:17
at ensure (http://127.0.0.1:8080/bower_components/angular/angular.js:1958:38)
at module (http://127.0.0.1:8080/bower_components/angular/angular.js:2032:14)
at http://127.0.0.1:8080/bower_components/angular/angular.js:4524:22
at forEach (http://127.0.0.1:8080/bower_components/angular/angular.js:321:20)
at loadModules (http://127.0.0.1:8080/bower_components/angular/angular.js:4508:5)
at createInjector (http://127.0.0.1:8080/bower_components/angular/angular.js:4430:19)
at doBootstrap (http://127.0.0.1:8080/bower_components/angular/angular.js:1710:20)
at bootstrap (http://127.0.0.1:8080/bower_components/angular/angular.js:1731:12)
Here is the content of .yo-rc.json
{
"generator-jhipster": {
"jhipsterVersion": "3.0.0",
"baseName": "blog",
"packageName": "com.albertofaci.blog",
"packageFolder": "com/albertofaci/blog",
"serverPort": "8080",
"authenticationType": "session",
"hibernateCache": "no",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "mongodb",
"devDatabaseType": "mongodb",
"prodDatabaseType": "mongodb",
"searchEngine": "no",
"buildTool": "gradle",
"enableSocialSignIn": false,
"rememberMeKey": "94cf21b11aff8d8d4a9b9b3724834876b995e5b1",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"es"
]
}}
node version: v6.0.0
npm version: 3.8.7
java 8
Any hints or ideas?
I had exactly the same problem as the OP, I changed to use the LTS version of Node as Gaël Marziou suggested. This fixed the problem.