question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npx ember new fails with `Cannot find module './environment'`

See original GitHub issue

The problem:

❯ npx -p ember-cli@3.25.2 ember new my-project -sg -sn -sb -b app --yarn
(node:4218) UnhandledPromiseRejectionWarning: Error: Cannot find module './environment'
Require stack:
- /Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/node_modules/workerpool/src/index.js
- /Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/lib/models/asset-size-printer.js
- /Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/lib/tasks/show-asset-sizes.js
- /Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/lib/utilities/require-as-hash.js
- /Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/lib/cli/index.js
- /Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/bin/ember
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/michal/.npm/_npx/4214/lib/node_modules/ember-cli/node_modules/workerpool/src/index.js:1:19)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4218) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4218) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I tried to go down on minor versions and 3.20.x (3.20.2) is first one that works for me:

❯ npx -p ember-cli@3.20.0 ember new my-project -sg -sn -sb -b app --yarn
installing app
Ember CLI v3.20.0

✨  Creating a new Ember app in /Users/michal/ember/my-project:
  create .editorconfig
  create .ember-cli
  create .eslintignore
  create .eslintrc.js
  create .template-lintrc.js
  create .travis.yml
  create .watchmanconfig
  create README.md
  create app/app.js
  create app/components/.gitkeep
  create app/controllers/.gitkeep
  create app/helpers/.gitkeep
  create app/index.html
  create app/models/.gitkeep
  create app/router.js
  create app/routes/.gitkeep
  create app/styles/app.css
  create app/templates/application.hbs
  create config/ember-cli-update.json
  create config/environment.js
  create config/optional-features.json
  create config/targets.js
  create ember-cli-build.js
  create .gitignore
  create package.json
  create public/robots.txt
  create testem.js
  create tests/helpers/.gitkeep
  create tests/index.html
  create tests/integration/.gitkeep
  create tests/test-helper.js
  create tests/unit/.gitkeep
  create vendor/.gitkeep

🎉  Successfully created project my-project.
👉   Get started by typing:

  $ cd my-project
  $ yarn start

Happy coding!

Why am I trying this? The command is actually extracted from ember-cli-update run. Which is failing on me.

I’m not sure what happened, successfully updated one app and second one failed. Now even if I go back in git history it fails on me. I think this started after I did global update of ember-cli.

I tried to wipe global npx cache:

trash ~/.npm/_npx

I tried different versions of node, removing volta re-installing global ember-cli, removing node_modules of the app (during ember-cli-update run).


Output from ember version --verbose && npm --version && yarn --version:

❯ ember version --verbose
ember-cli: 3.19.0
node: 14.16.0
v8: 8.4.371.19-node.18
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.16.1
modules: 83
nghttp2: 1.41.0
napi: 7
llhttp: 2.1.3
openssl: 1.1.1j
cldr: 37.0
icu: 67.1
tz: 2020a
unicode: 13.0
os: darwin x64

❯ npm --version
6.14.11

❯ yarn --version
1.22.10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
cecemelcommented, Mar 8, 2021

Just bumped into the same problem

2reactions
NullVoxPopulicommented, Mar 8, 2021

I ran in to this, too 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember init while upgrading to v3.0.0 fails with Cannot ... - GitHub
I am currently upgrading my v2.12.2 Ember app to v3.0.0. While upgrading after following the instructions in the releases page I got a...
Read more >
Ember CLI
i am trying to ember serve one app but it is throwing above error. ... Cannot find module './server' from path/ · Ember...
Read more >
ember-cli fails on --environment=production (Uncaught Error
I am using ember-cli and have a problem with selecting the production environment. Specifically, everything works when I run ember serve -- ...
Read more >
Dotenv : cannot find module : r/emberjs - Reddit
removed node_modules folder and package-lock.json and ran npm install,. npm install --dotenv-extended. But I still get the error. What should I ...
Read more >
Solved: Cannot find module react : npm install - YouTube
Transcript · Publish Your Own npm Module : Creating a Local Module (1 of 2) · How to solve npm command error ?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found