How to fix [ERROR] Could not resolve "path-browserify" in Astro Build 2.0? - astrojs

I recently upgraded my Blog made with Astro 1.0 to the new Astro 2.0 using the next command:
npm install astro#latest
But when I try to run my project in development mode with npm run dev I found the next error:
[ERROR] Could not resolve "path-browserify"
node_modules/#astrojs/rss/dist/util.js:1:18:
1 │ import npath from "path-browserify";
╵ ~~~~~~~~~~~~~~~~~
You can mark the path "path-browserify" as external to exclude it from the bundle, which will
remove this error.
/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:1604
let error = new Error(`${text}${summary}`);
^
Error: Build failed with 1 error:
node_modules/#astrojs/rss/dist/util.js:1:18: ERROR: Could not resolve "path-browserify"
at failureErrorWithLog (/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:1604:15)
at /Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:1056:28
at runOnEndCallbacks (/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:1476:61)
at buildResponseToResult (/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:1054:7)
at /Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:1166:14
at responseCallbacks.<computed> (/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:701:9)
at handleIncomingPacket (/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:756:9)
at Socket.readFromStdout (/Users/victoralvarado/Development/My Projects/vicbox-tech/node_modules/esbuild/lib/main.js:677:7)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12) {
errors: [
{
detail: undefined,
id: '',
location: {
column: 18,
file: 'node_modules/#astrojs/rss/dist/util.js',
length: 17,
line: 1,
lineText: 'import npath from "path-browserify";',
namespace: '',
suggestion: ''
},
notes: [
{
location: null,
text: 'You can mark the path "path-browserify" as external to exclude it from the bundle, which will remove this error.'
}
],
pluginName: '',
text: 'Could not resolve "path-browserify"'
}
],
warnings: []
}
I don’t know exactly why and I tried many things to fix that without a positive result.
The last thing that I do was update the npm dependencies with a simple command npm update and the error was going. It was that way how to solve the error.
I ran the npm update command expecting some deprecated library or dependency to update and fix the error.

Related

GraphQL build error when deploying at Vercel

I'm trying to deploy my Nextjs app to Vercel, I am using strapi backend deployed at Heroku...
Unfortunately I am stuck at this build error at Vercel....
I have googled and tried to find a solution but unfortunately I can't and have no idea what to do.
Any ideas appreciated....
> Build error occurred
Error: Unexpected token M in JSON at position 0
at new ApolloError (/vercel/path0/node_modules/#apollo/client/errors/errors.cjs:34:28)
at /vercel/path0/node_modules/#apollo/client/core/core.cjs:1595:19
at both (/vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:986:53)
at /vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:979:72
at new Promise (<anonymous>)
at Object.then (/vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:979:24)
at Object.error (/vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:987:49)
at notifySubscription (/vercel/path0/node_modules/zen-observable/lib/Observable.js:140:18)
at onNotify (/vercel/path0/node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.error (/vercel/path0/node_modules/zen-observable/lib/Observable.js:240:7) {
type: 'ApolloError',
graphQLErrors: [],
clientErrors: [],
networkError: {
name: 'ServerParseError',
response: { size: 0, timeout: 0 },
statusCode: 405,
bodyText: 'Method Not Allowed'
}
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1

Cypress error Cypress.moment.duration (moment is not defined)

I'm using Cypress and upgraded to version to v8.3.1 and a new error keeps showing up.
Cannot read property 'duration' of undefined
Because this error occurred during a after all hook we are skipping all of the remaining tests.
Location: node_modules/#cypress/code-coverage/support.jsat line210
cy.task('coverageReport', null, {
timeout: Cypress.moment.duration(3, 'minutes').asMilliseconds(),
^
log: false
})
It says that duration cannot be found since Cypress.moment doesn't exist.
I checked the changelog and they removed it:
Cypress.moment() has been removed. Please migrate to a different datetime formatter. See our recipe for example replacements. Addresses #8714.
But since I'm not directly using it, it's in the code coverage included in Cypress, I don't know how to fix it.
Somehow you've obtained an old version of #cypress/code-coverage.
Perhaps you upgraded Cypress and not the code-coverage package?
#cypress/code-coverage#3.2.0 - support.js
after(function generateReport() {
// when all tests finish, lets generate the coverage report
cy.task('coverageReport', {
timeout: Cypress.moment.duration(3, 'minutes').asMilliseconds()
})
})
#cypress/code-coverage#3.9.10 - support.js
after(function generateReport() {
...
cy.task('coverageReport', null, {
timeout: dayjs.duration(3, 'minutes').asMilliseconds(),
log: false
}).then((coverageReportFolder) => {
...
})
npm update #cypress/code-coverage should fix it

ERROR in Entry module not found: Error: Can't resolve something to do with webpack.config.js

I get an ERROR for re-bundling updated script after I imported import GoogleMap from './modules/GoogleMap’; and var googleMap = new GoogleMap(); inside the modules/scripts.js of a Wordpress app i am building. The full error reads:
`MacBook-Pro-2:wordpress Fighi$ gulp scripts
[14:28:28] Using gulpfile /Applications/MAMP/htdocs/wordpress/gulpfile.js
[14:28:29] Starting 'scripts'...
Hash: 7f21ae405761f9b513c9
Version: webpack 4.8.2
Time: 113ms
Built at: 12/18/2018 2:28:29 PM
ERROR in Entry module not found: Error: Can't resolve '/Applications/MAMP/htdocs/wordpress/wp-content/themes/university-test-sitejs/scripts.js' in '/Applications/MAMP/htdocs/wordpress’`
I took your advise one of the contributors advice and added this line of code to webpack.config.js file
module.exports = {
//...
resolve: {
extensions: ['.js', '.jsx']
}
};
Same ERROR ...
Your help would be greatly appreciated. I am kind of a newbie in building apps. Thank you

jhipster Project won't build for prod profile : gradlew -Pprod bootWar fails on taks webpack

ISSUE SOLVED see below for infos
after searching for a solutions for 2 days now i give up. I coudn't find a similar issue on the web and i don't know what to do.
Hope somebody can help there...
Issue
The application is building and running fine with gradlew -Pdev bootWar jibDockerBuild
However, the build won't work when selecting the prod profile:
gradlew -Pprod bootWar jibDockerBuild
Reference Exception
ERROR in Illegal State: referring to a type without a variable
{"filePath":"D:/dev/myApp/node_modules/#angular/forms/forms.d.ts",
"name":"FormGroupDirective","members":[]}
FULL EXCEPTION
The following is printed on execution:
D:\dev\myApp>gradlew -Pprod bootWar jibDockerBuild
> Task :yarn_install
yarn install v1.9.4
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents#1.2.4: The platform "win32" is incompatible with this module.
info "fsevents#1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > bootstrap#4.1.3" has unmet peer dependency "jquery#1.9.1 - 3".
warning " > bootstrap#4.1.3" has unmet peer dependency "popper.js#^1.14.3".
warning " > ngx-webstorage#2.0.1" has incorrect peer dependency "#angular/core#^5.0.0".
[5/5] Building fresh packages...
Done in 97.47s.
> Task :webpack
yarn run v1.9.4
$ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
$ rimraf build/{aot,www}
$ yarn run webpack --config webpack/webpack.prod.js --profile
$ node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config webpack/webpack.prod.js --profile
(node:28256) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
Hash: 6aab3d14e434ee333c51
Version: webpack 4.8.0
Time: 8812ms
Built at: 2018-10-07 18:52:03
6 assets
Entrypoint polyfills = app/polyfills.6aab3d14e434ee333c51.bundle.js
Entrypoint global = global.1e92ecdbfdaf2bb32590.css app/global.6aab3d14e434ee333c51.bundle.js
Entrypoint main = app/main.6aab3d14e434ee333c51.bundle.js
[0] ./src/main/webapp/app/app.main.ts 0 bytes {0} [built]
factory:4638ms building:3545ms = 8183ms
[2] ./src/main/webapp/content/css/global.css 39 bytes {1} [built]
factory:4639ms building:2778ms = 7417ms
[3] ./src/main/webapp/app/polyfills.ts 0 bytes {2} [built]
factory:4638ms building:3540ms = 8178ms
+ 1 hidden module
ERROR in Illegal State: referring to a type without a variable {"filePath":"D:/dev/myApp/node_modules/#angular/forms/forms.d.ts","name":"FormGroupDirective","members":[]}
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> Task :webpack FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webpack'.
> Process 'command 'yarn.cmd'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 58s
5 actionable tasks: 3 executed, 2 up-to-date
ENVIRONMENT
Windows 10
Using JHipster version installed locally in current project's node_modules
Executing jhipster:info
Options: from-cli: true
Welcome to the JHipster Information Sub-Generator
JHipster Version(s)
myApp#0.0.0 D:\dev\myApp
`-- generator-jhipster#5.4.1
JHipster configuration, a .yo-rc.json file generated in the root folder
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
"generator-jhipster": {
"promptValues": {
"packageName": "de.myApp.myApp",
"nativeLanguage": "de"
},
"jhipsterVersion": "5.4.1",
"applicationType": "monolith",
"baseName": "myApp",
"packageName": "de.myApp.myApp",
"packageFolder": "de/myApp/myApp",
"serverPort": "8080",
"authenticationType": "session",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "gradle",
"enableSwaggerCodegen": false,
"rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "yarn",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "de",
"languages": [
"de",
"en",
"fr"
],
"appsFolders": [
"myApp"
],
"directoryPath": "../",
"monitoring": "elk",
"consoleOptions": [
"curator"
],
"jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons"
}
}
</pre>
</details>
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
SKIPPED
Environment and Tools
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
git version 1.8.4.msysgit.0
node: v8.11.3
npm: 5.6.0
yarn: 1.9.4
Docker version 18.06.1-ce, build e68fc7a
docker-compose version 1.22.0, build f46880fe
I found the cause of the issue:
I obviously placed the ReactiveFormModul imports at the wrong place. I had it in a module "upwards", but actually, I had to place it into the module where I actually have the components defining the form. To be honest ... I don't understand exactly why this is an issue, maybe someone can clarify.
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '#angular/core';
import { RouterModule } from '#angular/router';
import { ReactiveFormsModule } from '#angular/forms';
*** other imports
#NgModule({
imports: [***, ReactiveFormsModule, *** ROUTER stuff,
declarations: [MyReactiveFormComponent],
schemas: [***]
})
export class MyReactiveFormModule {}
After this, I found also other issues that was working fine in the dev-build (again ... don't understand the reason. I guess that has to do with a stricter "compile" configuration):
The variable referencing the formGroup was declared "private". Therefore I got a compile Error on the prod profile. I had to change it so that it can be accessed by the html template.
Variables accessed in html must be public (or accessible by means of a getter method)
Accessing Form Controls in subsequent html elements must be "public"
Code-Example:
MyReactiveComponent.ts:
this.myForm = this.fb.group({
id: [this.myObject.id],
date: [this.myObject.date, Validators.required],
number: [this.myObject.number, [Validators.required, Validators.min(2), Validators.max(100)]],
dynamicOptions: this.fb.array([]),
prefilledOptions: [this.prefilledOptions, Validators.required]
});
MyReactiveComponent.html:
<div class="row justify-content-center">
<div class="col-8">
<form [formGroup]="myForm" id="myFormId" novalidate (ngSubmit)="save()" #editForm="ngForm">
<h2>Create or edit a Play</h2>
<div>
<jhi-alert-error></jhi-alert-error>
<div class="form-group">
<input type="number" class="form-control" formControlName="number" (blur)="updateNumber()" id="field_number" required min="2" jhiMin="2" max="100" jhiMax="100"/>
<div [hidden]="!(number?.dirty && number?.invalid)">
<small class="form-text text-danger"
[hidden]="!number?.errors?.required">
This field is required.
</small>
...
Accessing number in "number?.dirty" for example requires to have a getter-method to be able to access it:
get number() {
return this.myForm.get('number') as FormControl;
}
Hope that helps other when struggling...

How do I install Sinon?

Bashing my head against the wall:
Add
"sinon" : "latest"
to my bower.json. Install it.
Add sinon to my karma server:
files: [
'vendor/assets/bower_components/sinon/lib/sinon.js',
]
Paste the demo expectation into my spec:
it("calls the original function", function () {
var callback = sinon.spy();
var proxy = once(callback);
proxy();
assert(callback.called);
});
and:
TypeError: 'undefined' is not a function (evaluating 'sinon.spy()')
Why is this? How do I install sinon? Why haven't they bothered with an installation section on their github page?
I came to the same issue, and did the following :
in a command prompt, navigate to the root of your project and type :
npm install karma-sinon --save-dev
then in your karma.conf.js file add the following:
frameworks: ['jasmine', 'sinon']
It worked for me

Resources