I tried to build Ember application (Ember 4.2, ember-electron 3.1, electron 17.2.0) on MacOS 10.15 for win32 and all attempts gave different errors:
Default electron-forge squirrel target (ran as "ember electron:make --platform=win32 -prod" from project root): electron-winstaller failed to load 7z.exe.
With electron-forge-maker-nsis plugin (ran as "ember electron:make --platform=win32 -prod" from project root): "... path must be of type string.". Also the electron-forge-maker-nsis recomments instead use electron-builder directly.
With electron-builder: (ran from "/electron-app" folder as "yarn run dist") - ... failed creating mmap of ".....electron-app/dist/...app-name...-x64.nsis.7z"
So, what is an actual sequence of building the distribution for win32 on MacOS? Probably something was running from wrong directory?
Maybe the steps can be split and manually fix what is not set up yet in the new version of ember-electron? Or maybe it's a known issue with squirrel and some workaround exists?
Any hints are appreciated.
The application structure is:
app/
package.json
electron-app/
ember-dist/ (created after running in development mode)
src/
package.json (with nsis config)
In the electron-app/package.js lines for build:
"scripts": {
"dist": "electron-builder" (or "electron-builder --windows nsis:x64", also doesn't work)
}
"build": {
"appId": "an.Id",
"nsis": {
"oneClick": false,
"perMachine": true,
"runAfterFinish": true
}
}
Related
I am using this script in package.json
"scripts": {
"build": "rollup -c"
}
And would like to dynamically pass options to the rollup.config.js file, such as npm run build home, where 'home' is a variable that will build a particular bundle.
I manage to get to the rollup config file using "build": "rollup -c rollup.config.js" and I can access 'home' within an array by using
var argv = require('minimist')(process.argv.slice(2));
but still, as it was doing before without the addition in the package.json script, I get the error [!] Error: Could not resolve entry module (home). and no bundle gets created.
Using --home in the CLI hides it completely in the 16.17 version of node I'm using (managed fine with 14.x) for whatever reason.
Going in circles as ever with existing answers online. Thanks for the help!
I just install all the requirements and setup my new Mac with Apple Silicon M1 Chip for Nativescript 8 development following their guide on https://nativescript.org. Now I created a new project running the command:
ns create
This asks for a name and what flavor you want, I choose Angular. Now I want to start creating new components but when trying to run the following command:
ng g c my-component
I get the following error:
The generate command requires to be run in an Angular project, but a project definition could not be found.
I already have the angular cli installed (version 12 latest) globally. What command should I run to create components or other stuff like services or modules; or do I need another package to do so.
You're missing angular.json in your project. And did you already install NativeScript Schematics? (npm i --save-dev #nativescript/schematics)
The file should have the following content:
{
"version": 1,
"cli": {
"defaultCollection": "#nativescript/schematics"
},
"projects": {
"my-project-name": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "ns"
}
},
"defaultProject": "my-project-name"
}
Replace my-project-name with the name of your project and run the generate command again.
NativeScript Documentation
I use Add Angular Native Files with Visual Studio code. Pretty much works like ng g c componentName. You will just need to add the component to app.module.ts
More info here:
https://marketplace.visualstudio.com/items?itemName=joshdsommer.vscode-add-angular-native-files
I have set up an example project to demonstrate the issue:
https://github.com/garethrbrown/node-share-code
In this example there are two projects, example-api (a mini express project) and example-shared (a class library), both using Node JS / TypeScript. I want example-api to be able to use classes from example-shared to avoid code duplication. Having followed this example, I have referenced the example-shared project from package.json in example-api.
"dependencies": {
"example-shared": "file:..\\example-shared",
"express": "^4.17.1"
}
Having done this, and following running npm install, intellisense in VSCode sees ApiClass from the example-shared project and assists with the import.
I can then run by build command tsc --build via NPM, which succeeds.
I can also see that the sym link has been created in the example-api node_modules directory.
However, when I try to run the example-api project using the npm start script from under example-api, I get an error along the lines of:
Error: Cannot find module 'example-shared/apiClass'
Require stack:
...
code: 'MODULE_NOT_FOUND',
requireStack: [
...
]
I have tried running commands from different locations such as described here, but with no luck so far.
I'm using current stable versions of Node (14+) and NPM (7+).
I don't want to share via NPM or git repositories as I feel it will slow down development.
What am I doing wrong?
Seems like this is a discussed problem, see this post Typescript: How to resolve absolute modules paths for node.js?
I did not investigate further, but in the example-shared folder you can remove "outDir" from your example-shared/tsconfig.json and then run npm run build.
Unfortunately, this will emit the javascript files next to typescript files instead of placing them in a separate directory.
Finally, in the example-api run npm i, npm run build and npm start.
Now, Express will run because Node is using the javascript file instead of typescript file.
As per #mtbno's answer, the standard behavior without "outDir" is all js and map files will just be created next to each of your TypeScript files, which is super gross.
Without using some extra npm package or webpack or any of that, you can solve this by adding that "outDir" in your tsconfig, and then making a couple of tweaks to your package.json.
For argument's sake, say your root TypeScript file is called app.ts and your outDir folder is lib.
Relevant sections in your package.json can look like this:
"scripts": {
"build": "tsc --build",
"clean": "tsc --build --clean",
"start": "npm run build && node ./lib/app"
},
and
"main": "./lib/app",
And here's an example tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": ["es6"],
"sourceMap": true,
"outDir": "./lib",
},
"exclude": [
"node_modules"
]
}
After those 2 files are updated, then running npm run start should build out your lib folder with the compiled JavaScript, and your server should start up successfully. Note that if you previously did a build and you have "old" .js and .map files next to your TypeScript files, you may have to delete those manually because npm run clean won't do it for you.
I am following the tutorial for building a cli tool in Node here -- How to Build a Command Line (CLI) Tool in Node.
Environment:
Cmder
Node 9.5.0
npm 6.11.3
Windows 10
I am to the point where it has you create it as a shell cmd and the link it using npm link. Instead of running it in my shell--the same way create-react-app does--it instead errors with a Windows Script Host error:
Line: 1
Char: 1
Error: Invalid Character
Code: 800A03F6
Source: Microsoft JScript compilation error`
When I run where npm, I get:
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\smkar\AppData\Roaming\npm\npm
C:\Users\smkar\AppData\Roaming\npm\npm.cmd`
But when I run where caph, I get:
D:\Code\projects\cap-hooks\caph.js
C:\Users\smkar\AppData\Roaming\npm\caph
C:\Users\smkar\AppData\Roaming\npm\caph.cmd`
I'm pretty sure the error is because it's trying to open it from the local javascript file on the D drive, but I don't know how to fix it. I'm trying to make a CLI tool for fun/learning, and I want to be able to install the tool globally, but I haven't been able to proceed from here/fix this.
For reference here's the file and the package.json:
package.json
{
"name": "caph",
"version": "0.0.1",
"description": "An automated cli package for generating administrative
tools and components for React projects, written in
React Hooks.",
"main": "caph.js",
"bin": {
"caph": "./caph.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "smkarber",
"license": "ISC"
}
caph.js
#!/user/bin/env node
console.log("Hello World!");
After running npm link, I can use caph in my shell, but it immediately gives me a Windows Script Host error instead of running it in the shell. I have tried numerous Github issues returned from Google as well as a handful of Stackoverflow questions, but nothing seems to directly refer to fixing this situation, and I am unable to rectify the situation.
It must be /usr/ not /user/. So caph.js should look like:
#!/usr/bin/env node
console.log("Hello World!");
I want to integrate some kind of code linting for node.js in webstorm so I installed standard to my node.js project using:
npm instal standard --save-dev
It was installed and listed in the "devDependencies" section of package.json but when I run the command:
standard
in the console I get
'standard' is not recognized as an internal or external command
if you want to use it locally you have to include it in you scripts first in package.json
"scripts": {
"standard": "standard",
"standard::fix": "standard --fix"
}
and use npm run standard to run it. or if you are using yarn type yarn standard
The scripts are in node_modules\.bin.
So, either:
Add this to PATH before running standard, e.g.:
set PATH=%PATH%;node_modules\.bin
Run it in using node_modules\.bin\standard
Use #tarek's approach using package.json: https://stackoverflow.com/a/49026837/122441
"scripts": {
"test": "standard middlewares/validations.js"
}
Add above lines in package.json.
Here middlewares/validations.js is the path of the file to check.
Run -> npm test
If this file have any error you will get.