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

Error: Cannot find module 'package.json' #1898

Closed
ThomasKnobloch opened this issue Aug 30, 2016 · 23 comments
Closed

Error: Cannot find module 'package.json' #1898

ThomasKnobloch opened this issue Aug 30, 2016 · 23 comments
Labels
help wanted P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix

Comments

@ThomasKnobloch
Copy link

  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).
@ThomasKnobloch
Copy link
Author

The problem seems to be in the module ember-cli, the package child_process in the devDependencies of my package.json cannot be resolved.
There is no more issue when I delete this module in the package.json file of my project.

@filipesilva
Copy link
Contributor

We had the problem a while ago, but it's fixed in the latest versions.

@CoreyCole
Copy link

It's happening to me currently on:
angular-cli: 1.0.0-beta.16
node: v6.8.1
npm: 3.10.8

I've tried wiping node modules and reinstalling the cli after a fresh install of node and npm. Still no luck

@filipesilva
Copy link
Contributor

@CoreyCole what happened to you was probably fixed by #2178, available in beta.17.

@EpicButterz
Copy link

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

@filipesilva
Copy link
Contributor

This doesn't seem to happen to everyone, and I can't repro. Will leave it open for community help.

@AmitMY
Copy link
Contributor

AmitMY commented Nov 4, 2016

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.

@filipesilva filipesilva added type: bug/fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed type: RFC / discussion / question labels Nov 4, 2016
@filipesilva
Copy link
Contributor

@AmitMY got it, thank you!

kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng version
angular-cli: local (v1.0.0-beta.19, branch: fix-broken-e2e-tests)
node: 6.5.0
os: win32 x64

kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ npm install http --save
master-proj@0.0.0 D:\sandbox\master-proj
+-- UNMET PEER DEPENDENCY @types/request@0.0.30
`-- http@0.0.0

npm WARN optional Skipping failed optional dependency /angular-cli/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15
npm WARN angularfire2@2.0.0-beta.5 requires a peer of @types/request@0.0.30 but none was installed.

kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng version
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 Function.Module._load (D:\work\angular-cli\lib\bootstrap-local.js:64:22)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at AddonDiscovery.discoverAtPath (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:48:29)
    at Project.discoverAddons (D:\work\angular-cli\node_modules\angular-cli\lib\models\project.js:353:40)
    at Project.initializeAddons (D:\work\angular-cli\node_modules\angular-cli\lib\models\project.js:372:8)
    at Project.eachAddonCommand (D:\work\angular-cli\node_modules\angular-cli\lib\models\project.js:425:10)
    at module.exports (D:\work\angular-cli\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
    at CLI.<anonymous> (D:\work\angular-cli\node_modules\angular-cli\lib\cli\cli.js:34:26)
    at tryCatch (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:538:12)
    at invokeCallback (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:553:13)
    at publish (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:521:7)
    at flush (D:\work\angular-cli\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)

@filipesilva
Copy link
Contributor

As far as I can tell, it's something that is broken with ember-cli's addon discovery in the specific version we use.

@chris-gaona
Copy link

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.

@gglee89
Copy link

gglee89 commented Nov 18, 2016

Was this issue solved? :(

I'm getting the same issue on:

$ node --version
v5.1.0
$ npm -v
4.0.2
$ npm show angular-cli version
1.0.0-beta.20-4

This is my console output:

$ ng version
Cannot find module 'package.json'
Error: Cannot find module 'package.json'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at AddonDiscovery.discoverAtPath (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
    at Project.discoverAddons (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/project.js:353:40)
    at Project.initializeAddons (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/project.js:372:8)
    at Project.eachAddonCommand (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/project.js:425:10)
    at module.exports (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
    at CLI.<anonymous> (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/cli/cli.js:34:26)
    at tryCatch (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:538:12)
    at invokeCallback (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:553:13)
    at publish (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:521:7)
    at flush (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:2373:5)
    at doNTCallback0 (node.js:430:9)
    at process._tickCallback (node.js:359:13)

@MarkySparky
Copy link

I had the same issue. I removed the http package from my dev dependencies and it all started to work.

@beeman
Copy link
Contributor

beeman commented Dec 20, 2016

This happened to me when I made a copy of a project and ran ng serve in the copy. My solution was to nuke node_modules and run npm install.

I can not reproduce this with a new version of the app though.

@WeslleyDeSouza
Copy link

i had the same problem with FS from nodejs
so i had to remove fs package from my dev dependencies and it all started to work again.
"fs": "0.0.1-security",

@Caspain
Copy link

Caspain commented Dec 31, 2016

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

@Caspain
Copy link

Caspain commented Jan 7, 2017

There seems to be a correlation with streaming associated packages

@rikkouri
Copy link

Hi @filipesilva ,

I'm quite new to this world of nodejs/angular etc. but hopefully this helps diagnose a fix...

I found that running strace highlighted a lot of stat syscalls failing towards the end of its execution. It seems that ng is looking for a directory called node_modules/package.json/ which certainly didn't exist in my project. However I did notice that package-json does exist.

Adding a symlink between the two seem to fix the issue for me. Could this be a simple typo in a recent release?

Does this help?

ln -s node_modules/package-json/ node_modules/package.json

strace output for reference:

$ strace ng serve

...
open("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/package.json", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/index.js", 0x7fffc0f829b0) = -1 ENOENT (No such file or directory)
stat("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/index.json", 0x7fffc0f829b0) = -1 ENOENT (No such file or directory)
stat("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/index.node", 0x7fffc0f829b0) = -1 ENOENT (No such file or directory)
...
write(9, "\33[31mCannot find module 'package"..., 44Cannot find module 'package.json'
) = 44
write(9, "Error: Cannot find module 'packa"..., 2041Error: 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 (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:48:29)
    at Project.discoverAddons (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/project.js:296:40)
    at Project.initializeAddons (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/project.js:315:8)
    at Project.eachAddonCommand (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/project.js:368:10)
    at module.exports (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/cli/lookup-command.js:33:13)
    at CLI.<anonymous> (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/cli/cli.js:43:26)
    at tryCatch (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:538:12)
    at invokeCallback (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:553:13)
    at publish (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:521:7)
    at flush (/home/rikkouri/WebstormProjects/issue-1898/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)
) = 2041
...

@filipesilva
Copy link
Contributor

Fixed by #3695

@RanaAbdullah2017
Copy link

[ERROR] Error with .\node_modules\ionic-angular\package.json file: FILE_NOT_FOUND
[ERROR] Error with .\node_modules@ionic\app-scripts\package.json file: FILE_NOT_FOUND
I have an above Error when I write this command
ionic start Myapp tabs
Can u help me to solve this problem.

@beeman
Copy link
Contributor

beeman commented Dec 19, 2017

@RanaAbdullah2017 this is the Angular CLI issue thread, please look for the Ionic support channels when you have problems running Ionic.

@gabrielfrischer
Copy link

I like turtles

@saidevops014
Copy link

at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
Error: Cannot find module '/usr/local/share/.pm2/package.json'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at getPublicUrl (/usr/local/share/applications/cms-admin-ui/config/paths.js:26:19)
at Object. (/usr/local/share/applications/cms-admin-ui/config/paths.js:54:14)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)

when i start the application through PM2 am facing this issue please give me the solution for this ..

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

No branches or pull requests