amp-toolbox
amp-toolbox copied to clipboard
amp-toolbox does not build on Windows
Windows 10 64bit (Version 1909) node.js 12.16.0 npm 6.13.4
npm run build
lerna ERR! npm run build exited 2 in '@ampproject/toolbox-linter'
lerna ERR! npm run build stdout:
> @ampproject/[email protected] build C:\Users\mdmower\source\amp-toolbox\packages\linter
> tsc --resolveJsonModule --module commonjs --target es2018 --esModuleInterop --strictNullChecks --declaration --outDir dist src/*.ts
error TS6053: File 'src/*.ts' not found.
lerna ERR! npm run build stderr:
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ampproject/[email protected] build: `tsc --resolveJsonModule --module commonjs --target es2018 --esModuleInterop --strictNullChecks --declaration --outDir dist src/*.ts`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ampproject/[email protected] build script.
Is the /
the problem here? I don't own a windows machine which makes it hard for me to test this. //cc @ithinkihaveacat
Is the
/
the problem here? I don't own a windows machine which makes it hard for me to test this.
That's part of the problem. In general though, all npm scripts
definitions in all package.json
need to be written with cross-platform terminal commands (e.g. &&
and VARX=true somecmd
are also *nix shell specific). gulp
is often used for tasks like these (see amphtml project). A couple of other options are mentioned here: https://stackoverflow.com/questions/41548990/how-to-create-cross-platform-scripts-multiple-command-for-single-line-in-packa .
I think the problem here is that the Windows shell doesn't support globbing, so src/*.ts
doesn't get expanded. Some tools seem to build support for this themselves (like eslint
), but tsc
does not.
The next easiest fix might be to use tsconfig.json
to configure tsc
instead of switches to configure tsc
. There was a reason why I didn't do that in the first place but I can't remember why…
So amp-toolbox
should support Windows? What are the options for testing on Windows, are there Windows machines we can ssh into or something?
The postinstall
event for toolbox-optimizer
fails on Windows too:
PS D:\Projects\amp-toolbox> npm i
> [email protected] install D:\Projects\amp-toolbox\node_modules\husky
> node husky install
husky > Setting up git hooks
husky > Done
> [email protected] postinstall D:\Projects\amp-toolbox\node_modules\babel-runtime\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> [email protected] postinstall D:\Projects\amp-toolbox\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> @ampproject/toolbox-optimizer@file:packages/optimizer postinstall D:\Projects\amp-toolbox\node_modules\@ampproject\toolbox-optimizer
> scripts/init.js
'scripts' is not recognized as an internal or external command,
operable program or batch file.
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): EPERM: operation not permitted, lstat 'D:\Projects\amp-toolbox\node_modules\postcss-minify-selectors\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\google-closure-compiler-osx):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"x64,x86"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\google-closure-compiler-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"linux","arch":"x64,x86"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ampproject/toolbox-optimizer@file:packages/optimizer postinstall: `scripts/init.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ampproject/toolbox-optimizer@file:packages/optimizer postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\andre\AppData\Roaming\npm-cache\_logs\2020-05-13T18_56_09_791Z-debug.log
The fix for this one is to explicitly invoking node
when executing the script on package.json, as Windows won't understand shebangs:
...
"scripts": {
"postinstall": "node scripts/init.js"
},
...
@ithinkihaveacat I've been using tsconfig.json
in Bubblewrap modules without issues. Curious on what was the reason you didn't.