A complete Node.js project template using TypeScript and following general best practices.
License: BSD 3-Clause "New" or "Revised" License
Windows does not properly parse NPM run scripts that use semi-colons to separate commands. When one command is not required for success of the script, it should use || true
instead of a semi-colon.
TSLint is deprecated and should be replaced with ESLint.
Tried to use this on a windows 10 machine but couldn't make it work, got different errors, like tests doesn't work, if I run the test script I get the following error:
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" test --scripts-prepend-node-path=auto
> [email protected] test
> mocha
Error: No test files found
Process finished with exit code 1
If I try to run tests via WebStorm
C:\Users\Kennedy\WebstormProjects\xiv-chat-client\test\index.ts:3
import { expect } from 'chai';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.exports.requireOrImport (C:\Users\Kennedy\WebstormProjects\xiv-chat-client\node_modules\mocha\lib\esm-utils.js:56:20)
at async Object.exports.loadFilesAsync (C:\Users\Kennedy\WebstormProjects\xiv-chat-client\node_modules\mocha\lib\esm-utils.js:88:20)
at async singleRun (C:\Users\Kennedy\WebstormProjects\xiv-chat-client\node_modules\mocha\lib\cli\run-helpers.js:125:3)
at async Object.exports.handler (C:\Users\Kennedy\WebstormProjects\xiv-chat-client\node_modules\mocha\lib\cli\run.js:374:5)
Process finished with exit code 1
If I try to build it:
> [email protected] build
> npm run clean && npm run lint && tsc
> [email protected] clean
> (rm -r ./.nyc_output || true) && (rm -r ./coverage || true) && (rm -r ./dist || true)
'rm' is not recognized as an internal or external command,
operable program or batch file.
'true' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Users\Kennedy\WebstormProjects\xiv-chat-client
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c (rm -r ./.nyc_output || true) && (rm -r ./coverage || true) && (rm -r ./dist || true)
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Kennedy\AppData\Local\npm-cache\_logs\2021-09-04T20_49_56_774Z-debug.log
It would be useful to have an npm script that upgrades all dependencies to their latest version (not updating to the highest version allowed by package.json).
The ts-node package has v8.x available.
The nyc package should be upgraded to v14.0.0 and other dependencies should be upgraded as appropriate.
Hi there, thanks for maintaining this template. I just noticed that mocha has trouble finding the test files:
Environment:
$ node --version
v18.9.0
$ npm --version
8.19.1
$ uname -a
Linux desktop 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
Steps to reproduce:
git clone https://github.com/chriswells0/node-typescript-template.git test && \
cd test && \
rm -rf ./.git/ && \
git init && \
npm install && \
npm run build && \
npm run test
Output:
> [email protected] build
> npm run clean && npm run lint && tsc
> [email protected] clean
> (rm -r ./.nyc_output || true) && (rm -r ./coverage || true) && (rm -r ./dist || true)
rm: cannot remove './.nyc_output': No such file or directory
rm: cannot remove './coverage': No such file or directory
> [email protected] lint
> eslint --ext .ts --fix src/**/*.ts test/**/*.ts
> [email protected] test
> mocha
Error: No test files found
Thanks
The mocha package should be upgraded to v6.0.1 and node types should be upgraded to v10.12.27 or v11.9.5.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.