angular-cli: Error: Cannot find module 'package.json'

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Mac OS X 10.11.5 (El Capitan)
  2. Versions. Please run ng --version. If there’s nothing outputted, please run in a Terminal: node --version and paste the result here: angular-cli: 1.0.0-beta.11-webpack.8 node: 6.5.0 os: darwin x64
  3. Repro steps. Was this an app that wasn’t created using the CLI? What change did you do on your code? etc. clone from repository npm install --save-dev angular-cli@webpack ng version
  4. The log given by the failure. Normally this include a stack trace and some more information.
Cannot find module 'package.json'
Error: Cannot find module 'package.json'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at AddonDiscovery.discoverAtPath (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
    at Project.discoverAddons (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/project.js:353:40)
  1. Mention any other details that might be useful. ng version works fine outside of my project (using the global installation of angular-cli).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 23 (9 by maintainers)

Most upvoted comments

I like turtles

Just an FYI for anyone else dealing with this issue. I received a similar error message when I would run any angular cli commands (ng serve, ng version etc.) saying Error: Cannot find module 'package.json. I found out that the issue was caused by using a bad npm package (crypto), although I’m not entirely sure why that would have caused the error. When I removed that package from my package.json file, all the angular cli commands worked perfectly. I’m now using bcrypt instead.

Try ‘Npm install --save http’ It will add “http” on version 0.0.0 This reliably reproduces the problem Tried 3 times, and that is the error.

I can send a video if you want.

I’m having this same problem on beta 18.

Cannot find module 'package.json'
Error: Cannot find module 'package.json'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at AddonDiscovery.discoverAtPath (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
    at Project.discoverAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:353:40)
    at Project.initializeAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:372:8)
    at Project.eachAddonCommand (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:425:10)
    at module.exports (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
    at CLI.<anonymous> (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/cli/cli.js:34:26)
    at tryCatch (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:538:12)
    at invokeCallback (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:553:13)
    at publish (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:521:7)
    at flush (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:2373:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

angular-cli: 1.0.0-beta.18 node: v6.9.1 npm: 3.10.8

After much reading and analysis, the crypto package cause ember-cli to panic. Just remove it npm uninstall crypto --save