Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM Install fails #5

Open
polaski opened this issue Sep 17, 2022 · 0 comments
Open

NPM Install fails #5

polaski opened this issue Sep 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@polaski
Copy link

polaski commented Sep 17, 2022

Prerequisites

  • [O] Using npm
  • [O] Using an up-to-date main branch
  • [O] Using latest version of devtools. Check the docs for how to update
  • [O] Tried solutions mentioned in #400
  • [O] For issue in production release, add devtools output of DEBUG_PROD=true npm run build && npm start

Expected Behavior

When running npm install right after git clone, the install should not fail.

Current Behavior

npm install fails when it reaches the postinstall script.

Steps to Reproduce

There are two problems I have encountered:

First, when I run npm install, it installs dependencies and runs the postinstall script, at which point the script fails, complaining about the lack of "type": "module" declaration:

> charl-e@0.0.2 postinstall
> ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts

(node:37969) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/XXX/Projects/charl-e/.erb/scripts/check-native-dep.js:1
import fs from 'fs';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1048:15)
    at Module._compile (node:internal/modules/cjs/loader:1083:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Object.require.extensions.<computed> [as .js] (/Users/XXX/Projects/charl-e/node_modules/ts-node/src/index.ts:1608:43)

I don't know how this is working on your machine but I assume you have to put "type": "module" in package.json so I added it and tried running npm install again.

But now I have a second issue:

> ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts

TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///Users/XXX/Projects/charl-e/package.json" needs an import assertion of type "json"

In this case I thought this was because you're using some edge node.js version that supports features not supported by stable version, so I even tried updating my node.js version to the latest 18.9.0 and ran the command again, but it still fails with the same error.

My questions are:

  1. How are you able to use the import syntax without specifying the "type": "module" inside package.json? And do we need to add that line in the package.json file?
  2. Even after adding the module declaration I can't get it to work, how can I just run npm install without failing?
  3. Are there any other things I need to keep in mind when building locally?

Context

  1. How has this issue affected you?: I wanted to build the project locally and potentially contribute
  2. Did you make any changes? No

Your Environment

  • Node version : tried both 16.17.0 and 18.9.0
  • electron-react-boilerplate version or branch: I just cloned the exact same code here and ran
  • Operating System and version : Mac OS Monterey 12.5.1
@polaski polaski added the bug Something isn't working label Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant