npm WARN enoent ENOENT: no such file or directory, open ‘E:\Program Files\nodejs \package.json’ npm

在写一个网络爬虫的时候需要安装cheerio   ,直接在nodejs安装目录下安装时候,在执行npm install   cheerio  时候会遇到下面情况
npm WARN enoent ENOENT: no such file or directory, open ‘E:\Program Files\nodejs
\package.json’

解决方法是

在命令行切换到安装nodejs文件下的nodejs\node_modules\npm  后执行npm install cheerio

 

实例:

一、CentOS7:

[root@vultr-centos7 ~]# yum install npm
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 6.7 kB 00:00:00
epel | 3.2 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/3): epel/x86_64/updateinfo | 928 kB 00:00:00
(2/3): epel/x86_64/primary | 3.5 MB 00:00:00
(3/3): updates/7/x86_64/primary_db | 4.3 MB 00:00:00
Determining fastest mirrors
* base: ftp-srv2.kddilabs.jp
* epel: mirror.dmmlabs.jp
* extras: ftp-srv2.kddilabs.jp
* updates: ftp-srv2.kddilabs.jp
epel 12624/12624
Resolving Dependencies
–> Running transaction check
—> Package npm.x86_64 1:3.10.10-1.6.14.3.1.el7 will be installed
–> Processing Dependency: nodejs = 1:6.14.3-1.el7 for package: 1:npm-3.10.10-1.6.14.3.1.el7.x86_64
–> Running transaction check
—> Package nodejs.x86_64 1:6.14.3-1.el7 will be installed
–> Processing Dependency: libuv >= 1:1.9.1 for package: 1:nodejs-6.14.3-1.el7.x86_64
–> Processing Dependency: http-parser >= 2.7.0 for package: 1:nodejs-6.14.3-1.el7.x86_64
–> Processing Dependency: libuv.so.1()(64bit) for package: 1:nodejs-6.14.3-1.el7.x86_64
–> Processing Dependency: libhttp_parser.so.2()(64bit) for package: 1:nodejs-6.14.3-1.el7.x86_64
–> Running transaction check
—> Package http-parser.x86_64 0:2.7.1-5.el7_4 will be installed
—> Package libuv.x86_64 1:1.19.2-1.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================
Installing:
npm x86_64 1:3.10.10-1.6.14.3.1.el7 epel 2.5 M
Installing for dependencies:
http-parser x86_64 2.7.1-5.el7_4 base 28 k
libuv x86_64 1:1.19.2-1.el7 epel 121 k
nodejs x86_64 1:6.14.3-1.el7 epel 4.7 M

Transaction Summary
===========================================================================================================================================================
Install 1 Package (+3 Dependent packages)

Total download size: 7.4 M
Installed size: 26 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): libuv-1.19.2-1.el7.x86_64.rpm | 121 kB 00:00:00
(2/4): http-parser-2.7.1-5.el7_4.x86_64.rpm | 28 kB 00:00:00
(3/4): nodejs-6.14.3-1.el7.x86_64.rpm | 4.7 MB 00:00:00
(4/4): npm-3.10.10-1.6.14.3.1.el7.x86_64.rpm | 2.5 MB 00:00:00
———————————————————————————————————————————————————–
Total 24 MB/s | 7.4 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : http-parser-2.7.1-5.el7_4.x86_64 1/4
Installing : 1:libuv-1.19.2-1.el7.x86_64 2/4
Installing : 1:npm-3.10.10-1.6.14.3.1.el7.x86_64 3/4
Installing : 1:nodejs-6.14.3-1.el7.x86_64 4/4
Verifying : 1:libuv-1.19.2-1.el7.x86_64 1/4
Verifying : http-parser-2.7.1-5.el7_4.x86_64 2/4
Verifying : 1:nodejs-6.14.3-1.el7.x86_64 3/4
Verifying : 1:npm-3.10.10-1.6.14.3.1.el7.x86_64 4/4

Installed:
npm.x86_64 1:3.10.10-1.6.14.3.1.el7

Dependency Installed:
http-parser.x86_64 0:2.7.1-5.el7_4 libuv.x86_64 1:1.19.2-1.el7 nodejs.x86_64 1:6.14.3-1.el7

Complete!
[root@vultr-centos7 ~]# npm install katex
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
/root
└─┬ katex@0.10.0-beta
├── match-at@0.1.1
└─┬ nomnom@1.8.1
├─┬ chalk@0.4.0
│ ├── ansi-styles@1.0.0
│ ├── has-color@0.1.7
│ └── strip-ansi@0.1.1
└── underscore@1.6.0

npm WARN enoent ENOENT: no such file or directory, open ‘/root/package.json’
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.
[root@vultr-centos7 ~]#
[root@vultr-centos7 ~]#
[root@vultr-centos7 ~]# find / -name node_modules
/usr/lib/node_modules
/usr/lib/node_modules/npm/node_modules

。 。 。 。 。 。 。 。 。。 。 。。 。 。 。 。 。

[root@vultr-centos7 ~]# cd /usr/lib/node_modules/npm
[root@vultr-centos7 npm]# npm install katex
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm@3.10.10 /usr/lib/node_modules/npm
└─┬ katex@0.10.0-beta
├── match-at@0.1.1
└─┬ nomnom@1.8.1
├─┬ chalk@0.4.0
│ ├── ansi-styles@1.0.0
│ ├── has-color@0.1.7
│ └── strip-ansi@0.1.1
└── underscore@1.6.0

[root@vultr-centos7 npm]#

二、Ubuntu 16.04:

root@linode-Ubuntu:~# apt-get install npm
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:

。。。。。。。。。。。。。。。。。。。。。。。。。

root@linode-Ubuntu:~# npm install katex
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
/root
└─┬ katex@0.10.0-beta
├── match-at@0.1.1
└─┬ nomnom@1.8.1
├─┬ chalk@0.4.0
│ ├── ansi-styles@1.0.0
│ ├── has-color@0.1.7
│ └── strip-ansi@0.1.1
└── underscore@1.6.0

npm WARN enoent ENOENT: no such file or directory, open ‘/root/package.json’
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.
root@linode-Ubuntu:~# find / -name node_modules
/usr/share/npm/node_modules

。。。。。。。。。。。。。。。。。。。。。。。。。。。

root@linode-Ubuntu:~# cd /usr/share/npm/node_modules
root@linode-Ubuntu:/usr/share/npm/node_modules# ls
abbrev fs-write-stream-atomic lodash._createcache npm-package-arg semver
ansicolors glob lodash._getnative npm-registry-client sha
ansi-regex graceful-fs lodash.isarguments npm-user-validate slide
ansistyles has-unicode lodash.isarray once sorted-object
aproba hosted-git-info lodash.keys opener strip-ansi
archy iferr lodash.restparam osenv tar
async-some imurmurhash lodash.union path-is-inside text-table
chownr inflight lodash.uniq read uid-number
cmd-shim inherits lodash.without read-cmd-shim umask
columnify ini mkdirp readdir-scoped-modules unique-filename
config-chain init-package-json node-gyp read-installed unpipe
debuglog lockfile nopt read-package-json validate-npm-package-license
dezalgo lodash._baseindexof normalize-git-url read-package-tree validate-npm-package-name
editor lodash._baseuniq normalize-package-data realize-package-specifier which
fstream lodash._bindcallback npm-cache-filename request wrappy
fstream-npm lodash._cacheindexof npm-install-checks retry write-file-atomic
fs-vacuum lodash.clonedeep npmlog rimraf
root@linode-Ubuntu:/usr/share/npm/node_modules# cd ..
root@linode-Ubuntu:/usr/share/npm# ls
bin doc lib man node_modules npmrc package.json
root@linode-Ubuntu:/usr/share/npm#
root@linode-Ubuntu:/usr/share/npm#
root@linode-Ubuntu:/usr/share/npm# npm install katex
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm@3.5.2 /usr/share/npm
└── katex@0.10.0-beta extraneous

root@linode-Ubuntu:/usr/share/npm#

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注