react Cannot find module

song@u:~/src/JavaProject/demo-app/goods-front$ yarn start
yarn start v0.27.5
$ react-scripts start
module.js:471
    throw err;
    ^


Error: Cannot find module '../scripts/start'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.resolve (internal/module.js:27:19)
    at Object. (/home/song/src/JavaProject/demo-app/goods-front/node_modules/.bin/react-scripts:30:25)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)

error Command failed with exit code 1.


先说明我是Linux环境

导致该问的原因是:node_modules/.bin 目录下本来应该都是链接文件,但不知为何,在创建工程时都变成了实体文件,导致js中的相对路径取值错误,所以就报找不到 module的错误。

正确情况下使用(进入node_modules/.bin目录) 使用 ls -al 命令查看可以发现都是 ln 文件。

song@u:~/src/JavaProject/demo-app/goods-front1/node_modules/.bin$ ls -al
total 40
drwxrwxr-x   2 song song  4096 9月   8 15:55 .
drwxrwxr-x 891 song song 36864 9月   8 15:56 ..
lrwxrwxrwx   1 song song    18 9月   8 15:55 acorn -> ../acorn/bin/acorn
lrwxrwxrwx   1 song song    26 9月   8 15:55 ansi-html -> ../ansi-html/bin/ansi-html
lrwxrwxrwx   1 song song    25 9月   8 15:55 babylon -> ../babylon/bin/babylon.js
lrwxrwxrwx   1 song song    48 9月   8 15:55 browserslist -> ../autoprefixer/node_modules/browserslist/cli.js
lrwxrwxrwx   1 song song    20 9月   8 15:55 cssesc -> ../cssesc/bin/cssesc
lrwxrwxrwx   1 song song    16 9月   8 15:55 csso -> ../csso/bin/csso
lrwxrwxrwx   1 song song    34 9月   8 15:55 detect -> ../detect-port-alt/bin/detect-port
lrwxrwxrwx   1 song song    34 9月   8 15:55 detect-port -> ../detect-port-alt/bin/detect-port
lrwxrwxrwx   1 song song    15 9月   8 15:55 errno -> ../errno/cli.js
lrwxrwxrwx   1 song song    29 9月   8 15:55 escodegen -> ../escodegen/bin/escodegen.js
lrwxrwxrwx   1 song song    30 9月   8 15:55 esgenerate -> ../escodegen/bin/esgenerate.js
lrwxrwxrwx   1 song song    23 9月   8 15:55 eslint -> ../eslint/bin/eslint.js
lrwxrwxrwx   1 song song    25 9月   8 15:55 esparse -> ../esprima/bin/esparse.js
lrwxrwxrwx   1 song song    28 9月   8 15:55 esvalidate -> ../esprima/bin/esvalidate.js
lrwxrwxrwx   1 song song    28 9月   8 15:55 handlebars -> ../handlebars/bin/handlebars
lrwxrwxrwx   1 song song    12 9月   8 15:55 he -> ../he/bin/he
lrwxrwxrwx   1 song song    23 9月   8 15:55 html-minifier -> ../html-minifier/cli.js
lrwxrwxrwx   1 song song    21 9月   8 15:55 internal-ip -> ../internal-ip/cli.js
lrwxrwxrwx   1 song song    23 9月   8 15:55 jest -> ../jest-cli/bin/jest.js
lrwxrwxrwx   1 song song    35 9月   8 15:55 jest-runtime -> ../jest-runtime/bin/jest-runtime.js
lrwxrwxrwx   1 song song    18 9月   8 15:55 jsesc -> ../jsesc/bin/jsesc
lrwxrwxrwx   1 song song    19 9月   8 15:55 json5 -> ../json5/lib/cli.js
lrwxrwxrwx   1 song song    25 9月   8 15:55 js-yaml -> ../js-yaml/bin/js-yaml.js
lrwxrwxrwx   1 song song    22 9月   8 15:55 loose-envify -> ../loose-envify/cli.js
lrwxrwxrwx   1 song song    32 9月   8 15:55 miller-rabin -> ../miller-rabin/bin/miller-rabin
lrwxrwxrwx   1 song song    14 9月   8 15:55 mime -> ../mime/cli.js
lrwxrwxrwx   1 song song    20 9月   8 15:55 mkdirp -> ../mkdirp/bin/cmd.js
lrwxrwxrwx   1 song song    23 9月   8 15:55 multicast-dns -> ../multicast-dns/cli.js
lrwxrwxrwx   1 song song    14 9月   8 15:55 rc -> ../rc/index.js
lrwxrwxrwx   1 song song    37 9月   8 15:55 react-scripts -> ../react-scripts/bin/react-scripts.js
lrwxrwxrwx   1 song song    25 9月   8 15:55 regjsparser -> ../regjsparser/bin/parser
lrwxrwxrwx   1 song song    16 9月   8 15:55 rimraf -> ../rimraf/bin.js
lrwxrwxrwx   1 song song    18 9月   8 15:55 sane -> ../sane/src/cli.js
lrwxrwxrwx   1 song song    20 9月   8 15:55 semver -> ../semver/bin/semver
lrwxrwxrwx   1 song song    16 9月   8 15:55 sha.js -> ../sha.js/bin.js
lrwxrwxrwx   1 song song    23 9月   8 15:55 sshpk-conv -> ../sshpk/bin/sshpk-conv
lrwxrwxrwx   1 song song    23 9月   8 15:55 sshpk-sign -> ../sshpk/bin/sshpk-sign
lrwxrwxrwx   1 song song    25 9月   8 15:55 sshpk-verify -> ../sshpk/bin/sshpk-verify
lrwxrwxrwx   1 song song    22 9月   8 15:55 strip-indent -> ../strip-indent/cli.js
lrwxrwxrwx   1 song song    16 9月   8 15:55 svgo -> ../svgo/bin/svgo
lrwxrwxrwx   1 song song    21 9月   8 15:55 sw-precache -> ../sw-precache/cli.js
lrwxrwxrwx   1 song song    52 9月   8 15:55 uglifyjs -> ../html-minifier/node_modules/uglify-js/bin/uglifyjs
lrwxrwxrwx   1 song song    37 9月   8 15:55 uuid -> ../request/node_modules/uuid/bin/uuid
lrwxrwxrwx   1 song song    25 9月   8 15:55 webpack -> ../webpack/bin/webpack.js
lrwxrwxrwx   1 song song    47 9月   8 15:55 webpack-dev-server -> ../webpack-dev-server/bin/webpack-dev-server.js
lrwxrwxrwx   1 song song    18 9月   8 15:55 which -> ../which/bin/which

你可能感兴趣的:(react Cannot find module)