How to require js files with node webkit - node-webkit

I'm structuring my app like this:
dev
|-js
| |-C
| | |-app.js
| |-M
| |-folder.js
|-index.html
|-package.json
in index.html, I have
<script type="text/javascript" src="js/C/app.js"></script>
in app.js I have
var folders = require("js/M/folder.js")
When I run this app, I'm seeing:
Uncaught Error: Cannot find module 'js/M/folder.js' module.js:341
Module._resolveFilename module.js:341
Module._load module.js:280
Module.require module.js:367
require module.js:383
window.require
(anonymous function) app.js:6
I've tried using
"js/M/folder"
"js/M/folder.js"
"/js/M/folder"
"/js/M/folder.js"
"./js/M/folder"
"./js/M/folder.js"
"../../M/folder"
"../../M/folder.js"
And it never seems to find the file. I also noticed that the require function object doesn't seem to be the same one in the node documentation, as it has no resolve method attached to it.
Is there something fundamental I'm missing about node-webkit?

Nevermind. It looks like node-webkit doesn't like to run files located on a network share using the UNC.

Related

Cannot find module 'fs-extra' in CI Pipeline

Recently I've made some changes to the cypress project, adding the configFiles as per the documentation explains.
https://docs.cypress.io/api/plugins/configuration-api#Switch-between-multiple-configuration-files
Once done that the bitbucket pipeline keeps on failing throwing this error.
[69:0503/090921.933433:ERROR:zygote_host_impl_linux.cc(263)] Failed to adjust OOM score of renderer with pid 264: Permission denied (13)
[264:0503/090921.979708:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is swiftshader, ANGLE is
Your pluginsFile is invalid: /opt/atlassian/pipelines/agent/build/cypress/plugins/index.js
It threw an error when required, check the stack trace below:
Error: Cannot find module 'fs-extra'
Require stack:
- /opt/atlassian/pipelines/agent/build/cypress/plugins/index.js
- /root/.cache/Cypress/9.6.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js
- /root/.cache/Cypress/9.6.0/Cypress/resources/app/packages/server/lib/plugins/child/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
Does anyone have a clue as to why is that? I've tried multiple things with different docker images, changed the ts file to a js one, included the "pluginsFile": "cypress/plugins/index.js" in the cypress.json file, removing the node modules and the package-lock file and reinstalling. Nothing seems to work.
Something worth mentioning is that this only occurs when trying to run the project using the bitbucket pipeline and the cypress/included:9.6.0 docker image

Getting errors adding Buefy to Nuxt

I have a Nuxt project. I've installed Buefy via the steps outlined in the docs. That is:
Run npm i nuxt-buefy
Add 'nuxt-buefy' to modules in nuxt.config.js
I then run the dev server via
npm run dev
...and I get this gumf below. Thing is, Buefy doesn't say anything about having to first add postcss-custom-properties. What am I doing wrong?
ERROR Cannot find module 'postcss-custom-properties' 18:54:24
Require stack:
- C:\Users\mitya\Sync\dev\projects\rpar\node_modules\#nuxt\core\dist\core.js
Require stack:
- node_modules\#nuxt\core\dist\core.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.resolve (internal/modules/cjs/helpers.js:94:19)
at m (node_modules\jiti\dist\jiti.js:1:52953)
at Resolver.f [as _require] (node_modules\jiti\dist\jiti.js:1:53766)
at Resolver.requireModule (node_modules\#nuxt\core\dist\core.js:381:29)
at node_modules\#nuxt\webpack\dist\webpack.js:603:58
at Array.map (<anonymous>)
at PostcssConfig$1.loadPlugins (node_modules\#nuxt\webpack\dist\webpack.js:602:10)
at PostcssConfig$1.config (node_modules\#nuxt\webpack\dist\webpack.js:638:14)
at StyleLoader.postcss (node_modules\#nuxt\webpack\dist\webpack.js:909:39)
at StyleLoader.apply (node_modules\#nuxt\webpack\dist\webpack.js:969:12)
at WebpackClientConfig.rules (node_modules\#nuxt\webpack\dist\webpack.js:1357:28)
At the end, scaffolding a brand new Nuxt project was still the easiest to setup Buefy.
Probably that comparing both a new project and an old one and transferring the configuration is the way to go.

Deploying vue returns unexpted token < after build

I have had no problems with deploying my vue projects so far and uploading it to my website. However suddenly Im getting the following errormessage after I have been running
npm run build
and uploading the files in my distfolder.
Uncaught SyntaxError: Unexpected token '<' chunk-vendors.468a5298.js:1
Uncaught SyntaxError: Unexpected token
'<' app.f775d578.js:1
The only difference I can notice is that vue now seems to recommend using yarn.
I made a new project just for testing using yarn but with the same error.
vue create my-application
yarn install
yarn serve
yarn build
uploading content in distfolder to my website - same errormessage
Anyone else experienced this?
My old build works without any problems
Im using #vue/cli 4.5.6
I got it working now. Deleted the folder on my ftp and created a new one. Dont know this solved it but it did :)
If you are deploying your dist not to your root of the web, then one possible cause of this is an incorrect static assets path. Make sure both your css and js generated from npm run build are imported to the correct path from your web server
On dist/index.html, you will see something like this
<link href=/js/chunk-....js rel=prefetch>
This means that it's an absolute path (root of the web), when it's supposed to be relative from the dist folder like this:
<link href=js/chunk-....js rel=prefetch>
To easily fix this is, add publicPath key in your vue.config.js file:
module.exports = {
...
publicPath: ""
};
Then rebuild the project.

Nuxt.js: Client fails in production, but works during development

I'm using nuxt-edge to serve ssr for an existing rather complicated app. If I run yarn dev everything works great, but after building a production version I get only server-side rendered markup (that also looks as it should) and error on the client
TypeError: [nuxt] Error while mounting app: n.e is not a function
at V (cb1f209f20a02940261c.js:2)
at cb1f209f20a02940261c.js:2
at w (9664f928831af5328a28.js:formatted:4639)
at Generator._invoke (9664f928831af5328a28.js:formatted:4617)
at Generator.t.(anonymous function) [as next] (http://127.0.0.1:3000/_nuxt/9664f928831af5328a28.js:2:83522)
at r (9664f928831af5328a28.js:formatted:4038)
at u (9664f928831af5328a28.js:formatted:4052)
at 9664f928831af5328a28.js:formatted:4057
at new Promise (<anonymous>)
at 9664f928831af5328a28.js:formatted:4049
I have no idea how to debug minified js transpiled by webpack and babel, maybe I'm missing something obvious. Any thoughts are appreciated
So after some digging around I've found out that the problem was in dynamic importing routes by webpack.
Airbnb's babel-plugin-dynamic-import-node fixes the problem.
To allow pass babel config through .babelrc I've used nuxt-babel

Uncaught ReferenceError: require is not defined (Typescript)

I'm trying to make this example work in typescript. But for some reason I get an error when I run it: Uncaught ReferenceError: require is not defined
I don't really understand why I am getting this problem (I am quite new to Typescript and Vue).
The reason I use
import Vue = require('../libs/vue/index')
import * as vts from '../libs/vue-typescript-component/vue-typescript-component'
is because my node_modules are not a part of the project, so I link to the files in my libs folder, which as you can see is included in the wwwroot