我是使用NodeJS和npm的项目的新手。 我在Foundation 6.4中摆弄Foundation CLI,而我正在尝试安装第三方JS插件,在这种情况下为chart.js https://www.chartjs.org/
所以我跑了
npm install chart.js --save
如其文档中所述: https://www.chartjs.org/docs/latest/getting-started/installation.html
由于我想在基础项目中使用此命令,因此我发现从基础项目内部执行此命令是明智的,可以说整个项目的“根”。 但是,这样做时,在安装过程中会出现大量错误:
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\postcss-selector-parser-79b1786b\package.json'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\postcss-selector-parser-79b1786b\README.md'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\postcss-selector-parser-79b1786b\CHANGELOG.md'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\source-map-resolve-22d3c721\test\common.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uniq-b6c0c289\test\test.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\svgo-d6999a75\plugins\_collections.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\source-map-resolve-22d3c721\test\read.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\source-map-resolve-22d3c721\test\source-map-resolve.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\unique-filename-73563e8d\coverage\__root__\index.html'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\unique-filename-73563e8d\coverage\__root__\index.js.html'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\css\var\cssExpand.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\css\var\getStyles.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\css\var\isHiddenWithinTree.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\css\var\rboxStyle.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\css\var\rnumnonpx.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\src\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\css\var\swap.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\data.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\lib\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\src\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\async.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\test\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\equal.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\error_classes.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\formats.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\resolve.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\rules.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\schema_obj.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\ucs2length.js'
npm WARN tar ENOENT: no such file or directory, lstat 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\test\fixtures'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\compile\util.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\ajv-89eb8fee\lib\data.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\test\fixtures\with-unicode-flag\options.json'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\fs-extra-cf94d4f2\lib\fs\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-gyp-5150d3a7\gyp\tools\Xcode\README'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\handlebars-5e0aecc8\lib\handlebars\base.js'
npm WARN tar ENOENT: no such file or directory, lstat 'D:\foundationtests\node_modules\.staging\handlebars-5e0aecc8\lib'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\parse\regex.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\parse\token.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\test\fixtures\custom-functions\setter-expected.css'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\test\fixtures\custom-functions\setter.scss'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\test\fixtures\custom-functions\string-conversion-expected.css'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\test\fixtures\custom-functions\string-conversion.scss'
npm WARN tar ENOENT: no such file or directory, lstat 'D:\foundationtests\node_modules\.staging\jsdom-afeff42d\lib\jsdom\living\xhr'
npm WARN tar ENOENT: no such file or directory, lstat 'D:\foundationtests\node_modules\.staging\jsdom-afeff42d\lib'
此外,每次执行安装时,这些错误似乎都不同。
D:\foundationtests>npm install --save chart.js
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\fined-0dc44eaf\package.json'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\parse-filepath-dd59234a\package.json'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\parse-filepath-dd59234a\README.md'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\fined-0dc44eaf\README.md'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-relative-8f0e46f4\package.json'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-absolute-6dc5e586\package.json'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\parse-filepath-dd59234a\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\fined-0dc44eaf\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-relative-8f0e46f4\README.md'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-absolute-6dc5e586\README.md'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-relative-8f0e46f4\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\parse-filepath-dd59234a\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\fined-0dc44eaf\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-relative-8f0e46f4\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-absolute-6dc5e586\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\is-absolute-6dc5e586\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\gulp-cli-b31321ab\lib\versioned\^4.0.0-alpha.2\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\lib\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\lib\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\src\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\src\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass\base.h'
npm WARN tar ENOENT: no such file or directory, lstat 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\test'
npm WARN tar ENOENT: no such file or directory, lstat 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\test'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass\context.h'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass\functions.h'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-transform-dotall-regex-1df1d1be\test\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\@babel\plugin-proposal-unicode-property-regex-8ad643ab\test\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass\values.h'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass\version.h'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass\version.h.in'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\include\sass2scss.h'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\INSTALL'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\node-sass-e9c9e34c\src\libsass\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\http.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\http.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\http.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\https.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\https.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\https.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\mailto.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\mailto.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\mailto.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\urn-uuid.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\urn-uuid.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\urn-uuid.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\urn.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\urn.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\schemes\urn.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\uri.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\uri.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\uri.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\util.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\util.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\uri-js-a59e23e7\dist\esnext\util.js.map'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\fs-extra-cf94d4f2\lib\move\index.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\jquery-e95abfa6\src\queue\delay.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\browser-sync-ui-18c2e4d5\public\js\app.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\base-config.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\calendar.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\constructor.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\en.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\formats.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\invalid.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\lists.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\locale.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\locales.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\ordinal.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\pre-post-format.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\prototype.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\relative.js'
npm WARN tar ENOENT: no such file or directory, open 'D:\foundationtests\node_modules\.staging\moment-01d97eee\src\lib\locale\set.js'
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/har-validator/-/har-validator-5.1.2.tgz
npm ERR! 404
npm ERR! 404 'har-validator@5.1.2' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'foundationtests'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
当我从INSIDE的nodeJS文件夹中运行命令时,一切正常。
D:\nodeJS\node-v10.16.0-win-x64>npm install --save chart.js
+ chart.js@2.8.0
added 6 packages from 8 contributors in 1.403s
╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.9.0 -> 6.10.2 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.10.2 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯
但是,无论我做什么,最终安装和集成似乎都不起作用。 如文档和教程中所述,我添加了
import Chart from 'chart.js';
var myChart = new Chart(ctx, {...});
到基础项目的app.js,但是当我重新启动基础监视时,出现错误:
[10:38:51] Error in plugin "webpack-stream"
Message:
./src/assets/js/app.js
Module not found: Error: Can't resolve 'chart.js' in 'D:\foundationtests\src\assets\js'
resolve 'chart.js' in 'D:\foundationtests\src\assets\js'
Parsed request is a module
using description file: D:\foundationtests\package.json (relative path: ./src/assets/js)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
D:\foundationtests\src\assets\js\node_modules doesn't exist or is not a directory
D:\foundationtests\src\assets\node_modules doesn't exist or is not a directory
D:\foundationtests\src\node_modules doesn't exist or is not a directory
D:\node_modules doesn't exist or is not a directory
looking for modules in D:\foundationtests\node_modules
using description file: D:\foundationtests\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\foundationtests\package.json (relative path: ./node_modules/chart.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\foundationtests\node_modules\chart.js doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
D:\foundationtests\node_modules\chart.js.wasm doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
D:\foundationtests\node_modules\chart.js.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\foundationtests\node_modules\chart.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\foundationtests\node_modules\chart.js.json doesn't exist
as directory
D:\foundationtests\node_modules\chart.js doesn't exist
[D:\foundationtests\src\assets\js\node_modules]
[D:\foundationtests\src\assets\node_modules]
[D:\foundationtests\src\node_modules]
[D:\node_modules]
[D:\foundationtests\node_modules\chart.js]
[D:\foundationtests\node_modules\chart.js.wasm]
[D:\foundationtests\node_modules\chart.js.mjs]
[D:\foundationtests\node_modules\chart.js.js]
[D:\foundationtests\node_modules\chart.js.json]
@ ./src/assets/js/app.js 3:0-29
@ multi ./src/assets/js/app.js
Details:
domain: [object Object]
domainThrown: true
[10:38:51] 'build' errored after 13 s
[10:38:51] 'default' errored after 13 s
[10:38:51] The following tasks did not complete: images
[10:38:51] Did you forget to signal async completion?
Error: foundation-zurb-template@1.0.0 start: `gulp`
Exit status 1
at EventEmitter.<anonymous> (D:\nodeJS\node-v10.16.0-win-x64\node_modules\foundation-cli\node_modules\npm\lib\utils\lifecycle.js:217:16)
at EventEmitter.emit (events.js:198:13)
at ChildProcess.<anonymous> (D:\nodeJS\node-v10.16.0-win-x64\node_modules\foundation-cli\node_modules\npm\lib\utils\spawn.js:24:14)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
因此,或者我在集成部分做错了什么,或者在安装过程中缺少了什么。但是我不知何故地想出了办法,让它运行起来...
编辑: 我应该补充一点,我在尝试执行安装的计算机上没有管理员权限。安装Foundation ZURB模板等并不会造成任何问题,所以我想这应该不是问题,但是为了完整起见,我只想提及它。
答案 0 :(得分:0)
这是npm中的一个已知错误/问题。尝试rm -rf node_modules
,再试一次,然后检查是否可以升级npm。